2014-10-31 18:21:37 -04:00
|
|
|
:mod:`sys` -- system specific functions
|
|
|
|
=======================================
|
2014-10-30 21:37:19 -04:00
|
|
|
|
|
|
|
.. module:: sys
|
|
|
|
:synopsis: system specific functions
|
|
|
|
|
|
|
|
Functions
|
|
|
|
---------
|
|
|
|
|
2016-05-01 06:42:36 -04:00
|
|
|
.. function:: exit(retval=0)
|
2014-10-30 21:37:19 -04:00
|
|
|
|
2016-05-01 06:42:36 -04:00
|
|
|
Terminate current program with a given exit code. Underlyingly, this
|
|
|
|
function raise as ``SystemExit`` exception. If an argument is given, its
|
|
|
|
value given as an argument to ``SystemExit``.
|
2014-10-30 21:37:19 -04:00
|
|
|
|
2016-05-01 06:44:06 -04:00
|
|
|
.. function:: print_exception(exc, file=sys.stdout)
|
2014-12-06 17:18:37 -05:00
|
|
|
|
2016-05-01 06:44:06 -04:00
|
|
|
Print exception with a traceback to a file-like object `file` (or
|
2014-12-06 17:18:37 -05:00
|
|
|
``sys.stdout`` by default).
|
|
|
|
|
2014-12-19 17:10:38 -05:00
|
|
|
.. admonition:: Difference to CPython
|
2014-12-22 08:42:30 -05:00
|
|
|
:class: attention
|
2014-12-19 17:10:38 -05:00
|
|
|
|
|
|
|
This function appears in the ``traceback`` module in CPython.
|
|
|
|
|
2014-10-30 21:37:19 -04:00
|
|
|
Constants
|
|
|
|
---------
|
|
|
|
|
|
|
|
.. data:: argv
|
|
|
|
|
2016-05-01 06:38:45 -04:00
|
|
|
A mutable list of arguments the current program was started with.
|
2014-10-30 21:37:19 -04:00
|
|
|
|
|
|
|
.. data:: byteorder
|
|
|
|
|
2016-05-01 06:38:45 -04:00
|
|
|
The byte order of the system ("little" or "big").
|
2014-10-30 21:37:19 -04:00
|
|
|
|
2016-05-01 06:59:34 -04:00
|
|
|
.. data:: implementation
|
|
|
|
|
|
|
|
Object with information about the current Python implementation. For
|
|
|
|
MicroPython, it has following attributes:
|
|
|
|
|
|
|
|
* `name` - string "micropython"
|
|
|
|
* `version` - tuple (major, minor, micro), e.g. (1, 7, 0)
|
|
|
|
|
|
|
|
This object is the recommended way to distinguish MicroPython from other
|
|
|
|
Python implementations (note that it still may not exist in the very
|
|
|
|
minimal ports).
|
|
|
|
|
|
|
|
.. admonition:: Difference to CPython
|
|
|
|
:class: attention
|
|
|
|
|
|
|
|
CPython mandates more attributes for this object, but the actual useful
|
|
|
|
bare minimum is implemented in MicroPython.
|
|
|
|
|
2016-05-01 06:32:15 -04:00
|
|
|
.. data:: modules
|
|
|
|
|
|
|
|
Dictionary of loaded modules. On some ports, it may not include builtin
|
|
|
|
modules.
|
|
|
|
|
2014-10-30 21:37:19 -04:00
|
|
|
.. data:: path
|
|
|
|
|
2016-05-01 06:38:45 -04:00
|
|
|
A mutable list of directories to search for imported modules.
|
2014-10-30 21:37:19 -04:00
|
|
|
|
|
|
|
.. data:: platform
|
|
|
|
|
2015-06-04 18:53:26 -04:00
|
|
|
The platform that MicroPython is running on. This is "pyboard" on the
|
2014-12-19 17:10:38 -05:00
|
|
|
pyboard and provides a robust way of determining if a script is running
|
|
|
|
on the pyboard or not.
|
2014-10-30 21:37:19 -04:00
|
|
|
|
|
|
|
.. data:: stderr
|
|
|
|
|
2016-05-01 06:38:45 -04:00
|
|
|
Standard error stream.
|
2014-10-30 21:37:19 -04:00
|
|
|
|
|
|
|
.. data:: stdin
|
|
|
|
|
2016-05-01 06:38:45 -04:00
|
|
|
Standard input stream.
|
2014-10-30 21:37:19 -04:00
|
|
|
|
|
|
|
.. data:: stdout
|
|
|
|
|
2016-05-01 06:38:45 -04:00
|
|
|
Standard output stream.
|
2014-10-30 21:37:19 -04:00
|
|
|
|
|
|
|
.. data:: version
|
|
|
|
|
2016-05-01 06:38:45 -04:00
|
|
|
Python language version that this implementation conforms to, as a string.
|
2014-10-30 21:37:19 -04:00
|
|
|
|
|
|
|
.. data:: version_info
|
|
|
|
|
2016-05-01 06:38:45 -04:00
|
|
|
Python language version that this implementation conforms to, as a tuple of ints.
|