<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><title>Python: built-in module sys</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head><body bgcolor="#f0f0f8"> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>sys</strong></big></big></font></td ><td align=right valign=bottom ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br>(built-in)<br><a href="http://docs.python.org/library/sys">Module Docs</a></font></td></tr></table> <p><tt>This module provides access to some objects used or maintained by the<br> interpreter and to functions that interact strongly with the interpreter.<br> <br> Dynamic objects:<br> <br> argv -- command line arguments; argv[0] is the script pathname if known<br> path -- module search path; path[0] is the script directory, else ''<br> modules -- dictionary of loaded modules<br> <br> displayhook -- called to show results in an interactive session<br> excepthook -- called to handle any uncaught exception other than SystemExit<br> To customize printing in an interactive session or to install a custom<br> top-level exception handler, assign other functions to replace these.<br> <br> stdin -- standard input file object; used by input()<br> stdout -- standard output file object; used by print()<br> stderr -- standard error object; used for error messages<br> By assigning other file objects (or objects that behave like files)<br> to these, it is possible to redirect all of the interpreter's I/O.<br> <br> last_type -- type of last uncaught exception<br> last_value -- value of last uncaught exception<br> last_traceback -- traceback of last uncaught exception<br> These three are only available in an interactive session after a<br> traceback has been printed.<br> <br> Static objects:<br> <br> float_info -- a dict with information about the float implementation.<br> int_info -- a struct sequence with information about the int implementation.<br> maxsize -- the largest supported length of containers.<br> maxunicode -- the largest supported character<br> builtin_module_names -- tuple of module names built into this interpreter<br> subversion -- subversion information of the build as tuple<br> version -- the version of this interpreter as a string<br> version_info -- version information as a named tuple<br> hexversion -- version information encoded as a single integer<br> copyright -- copyright notice pertaining to this interpreter<br> platform -- platform identifier<br> executable -- pathname of this Python interpreter<br> prefix -- prefix used to find the Python library<br> exec_prefix -- prefix used to find the machine-specific Python library<br> float_repr_style -- string indicating the style of repr() output for floats<br> __stdin__ -- the original stdin; don't touch!<br> __stdout__ -- the original stdout; don't touch!<br> __stderr__ -- the original stderr; don't touch!<br> __displayhook__ -- the original displayhook; don't touch!<br> __excepthook__ -- the original excepthook; don't touch!<br> <br> Functions:<br> <br> <a href="#-displayhook">displayhook</a>() -- print an object to the screen, and save it in builtins._<br> <a href="#-excepthook">excepthook</a>() -- print an exception and its traceback to sys.stderr<br> <a href="#-exc_info">exc_info</a>() -- return thread-safe information about the current exception<br> <a href="#-exit">exit</a>() -- exit the interpreter by raising SystemExit<br> <a href="#-getdlopenflags">getdlopenflags</a>() -- returns flags to be used for dlopen() calls<br> <a href="#-getprofile">getprofile</a>() -- get the global profiling function<br> <a href="#-getrefcount">getrefcount</a>() -- return the reference count for an object (plus one :-)<br> <a href="#-getrecursionlimit">getrecursionlimit</a>() -- return the max recursion depth for the interpreter<br> <a href="#-getsizeof">getsizeof</a>() -- return the size of an object in bytes<br> <a href="#-gettrace">gettrace</a>() -- get the global debug tracing function<br> <a href="#-setcheckinterval">setcheckinterval</a>() -- control how often the interpreter checks for events<br> <a href="#-setdlopenflags">setdlopenflags</a>() -- set the flags to be used for dlopen() calls<br> <a href="#-setprofile">setprofile</a>() -- set the global profiling function<br> <a href="#-setrecursionlimit">setrecursionlimit</a>() -- set the max recursion depth for the interpreter<br> <a href="#-settrace">settrace</a>() -- set the global debug tracing function</tt></p> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#eeaa77"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> <td width="100%"><dl><dt><a name="-__displayhook__"><strong>__displayhook__</strong></a> = displayhook(...)</dt><dd><tt><a href="#-displayhook">displayhook</a>(object) -> None<br> <br> Print an object to sys.stdout and also save it in builtins.</tt></dd></dl> <dl><dt><a name="-__excepthook__"><strong>__excepthook__</strong></a> = excepthook(...)</dt><dd><tt><a href="#-excepthook">excepthook</a>(exctype, value, traceback) -> None<br> <br> Handle an exception by displaying it with a traceback on sys.stderr.</tt></dd></dl> <dl><dt><a name="-call_tracing"><strong>call_tracing</strong></a>(...)</dt><dd><tt><a href="#-call_tracing">call_tracing</a>(func, args) -> object<br> <br> Call func(*args), while tracing is enabled. The tracing state is<br> saved, and restored afterwards. This is intended to be called from<br> a debugger from a checkpoint, to recursively debug some other code.</tt></dd></dl> <dl><dt><a name="-callstats"><strong>callstats</strong></a>(...)</dt><dd><tt><a href="#-callstats">callstats</a>() -> tuple of integers<br> <br> Return a tuple of function call statistics, if CALL_PROFILE was defined<br> when Python was built. Otherwise, return None.<br> <br> When enabled, this function returns detailed, implementation-specific<br> details about the number of function calls executed. The return value is<br> a 11-tuple where the entries in the tuple are counts of:<br> 0. all function calls<br> 1. calls to PyFunction_Type objects<br> 2. PyFunction calls that do not create an argument tuple<br> 3. PyFunction calls that do not create an argument tuple<br> and bypass PyEval_EvalCodeEx()<br> 4. PyMethod calls<br> 5. PyMethod calls on bound methods<br> 6. PyType calls<br> 7. PyCFunction calls<br> 8. generator calls<br> 9. All other calls<br> 10. Number of stack pops performed by call_function()</tt></dd></dl> <dl><dt><a name="-displayhook"><strong>displayhook</strong></a>(...)</dt><dd><tt><a href="#-displayhook">displayhook</a>(object) -> None<br> <br> Print an object to sys.stdout and also save it in builtins.</tt></dd></dl> <dl><dt><a name="-exc_info"><strong>exc_info</strong></a>(...)</dt><dd><tt><a href="#-exc_info">exc_info</a>() -> (type, value, traceback)<br> <br> Return information about the most recent exception caught by an except<br> clause in the current stack frame or in an older stack frame.</tt></dd></dl> <dl><dt><a name="-excepthook"><strong>excepthook</strong></a>(...)</dt><dd><tt><a href="#-excepthook">excepthook</a>(exctype, value, traceback) -> None<br> <br> Handle an exception by displaying it with a traceback on sys.stderr.</tt></dd></dl> <dl><dt><a name="-exit"><strong>exit</strong></a>(...)</dt><dd><tt><a href="#-exit">exit</a>([status])<br> <br> Exit the interpreter by raising SystemExit(status).<br> If the status is omitted or None, it defaults to zero (i.e., success).<br> If the status is numeric, it will be used as the system exit status.<br> If it is another kind of object, it will be printed and the system<br> exit status will be one (i.e., failure).</tt></dd></dl> <dl><dt><a name="-getcheckinterval"><strong>getcheckinterval</strong></a>(...)</dt><dd><tt><a href="#-getcheckinterval">getcheckinterval</a>() -> current check interval; see <a href="#-setcheckinterval">setcheckinterval</a>().</tt></dd></dl> <dl><dt><a name="-getdefaultencoding"><strong>getdefaultencoding</strong></a>(...)</dt><dd><tt><a href="#-getdefaultencoding">getdefaultencoding</a>() -> string<br> <br> Return the current default string encoding used by the Unicode <br> implementation.</tt></dd></dl> <dl><dt><a name="-getdlopenflags"><strong>getdlopenflags</strong></a>(...)</dt><dd><tt><a href="#-getdlopenflags">getdlopenflags</a>() -> int<br> <br> Return the current value of the flags that are used for dlopen calls.<br> The flag constants are defined in the ctypes and DLFCN modules.</tt></dd></dl> <dl><dt><a name="-getfilesystemencoding"><strong>getfilesystemencoding</strong></a>(...)</dt><dd><tt><a href="#-getfilesystemencoding">getfilesystemencoding</a>() -> string<br> <br> Return the encoding used to convert Unicode filenames in<br> operating system filenames.</tt></dd></dl> <dl><dt><a name="-getprofile"><strong>getprofile</strong></a>(...)</dt><dd><tt><a href="#-getprofile">getprofile</a>()<br> <br> Return the profiling function set with sys.setprofile.<br> See the profiler chapter in the library manual.</tt></dd></dl> <dl><dt><a name="-getrecursionlimit"><strong>getrecursionlimit</strong></a>(...)</dt><dd><tt><a href="#-getrecursionlimit">getrecursionlimit</a>()<br> <br> Return the current value of the recursion limit, the maximum depth<br> of the Python interpreter stack. This limit prevents infinite<br> recursion from causing an overflow of the C stack and crashing Python.</tt></dd></dl> <dl><dt><a name="-getrefcount"><strong>getrefcount</strong></a>(...)</dt><dd><tt><a href="#-getrefcount">getrefcount</a>(object) -> integer<br> <br> Return the reference count of object. The count returned is generally<br> one higher than you might expect, because it includes the (temporary)<br> reference as an argument to <a href="#-getrefcount">getrefcount</a>().</tt></dd></dl> <dl><dt><a name="-getsizeof"><strong>getsizeof</strong></a>(...)</dt><dd><tt><a href="#-getsizeof">getsizeof</a>(object, default) -> int<br> <br> Return the size of object in bytes.</tt></dd></dl> <dl><dt><a name="-gettrace"><strong>gettrace</strong></a>(...)</dt><dd><tt><a href="#-gettrace">gettrace</a>()<br> <br> Return the global debug tracing function set with sys.settrace.<br> See the debugger chapter in the library manual.</tt></dd></dl> <dl><dt><a name="-intern"><strong>intern</strong></a>(...)</dt><dd><tt><a href="#-intern">intern</a>(string) -> string<br> <br> ``Intern'' the given string. This enters the string in the (global)<br> table of interned strings whose purpose is to speed up dictionary lookups.<br> Return the string itself or the previously interned string object with the<br> same value.</tt></dd></dl> <dl><dt><a name="-setcheckinterval"><strong>setcheckinterval</strong></a>(...)</dt><dd><tt><a href="#-setcheckinterval">setcheckinterval</a>(n)<br> <br> Tell the Python interpreter to check for asynchronous events every<br> n instructions. This also affects how often thread switches occur.</tt></dd></dl> <dl><dt><a name="-setdlopenflags"><strong>setdlopenflags</strong></a>(...)</dt><dd><tt><a href="#-setdlopenflags">setdlopenflags</a>(n) -> None<br> <br> Set the flags used by the interpreter for dlopen calls, such as when the<br> interpreter loads extension modules. Among other things, this will enable<br> a lazy resolving of symbols when importing a module, if called as<br> sys.<a href="#-setdlopenflags">setdlopenflags</a>(0). To share symbols across extension modules, call as<br> sys.<a href="#-setdlopenflags">setdlopenflags</a>(ctypes.RTLD_GLOBAL). Symbolic names for the flag modules<br> can be either found in the ctypes module, or in the DLFCN module. If DLFCN<br> is not available, it can be generated from /usr/include/dlfcn.h using the<br> h2py script.</tt></dd></dl> <dl><dt><a name="-setfilesystemencoding"><strong>setfilesystemencoding</strong></a>(...)</dt><dd><tt><a href="#-setfilesystemencoding">setfilesystemencoding</a>(string) -> None<br> <br> Set the encoding used to convert Unicode filenames in<br> operating system filenames.</tt></dd></dl> <dl><dt><a name="-setprofile"><strong>setprofile</strong></a>(...)</dt><dd><tt><a href="#-setprofile">setprofile</a>(function)<br> <br> Set the profiling function. It will be called on each function call<br> and return. See the profiler chapter in the library manual.</tt></dd></dl> <dl><dt><a name="-setrecursionlimit"><strong>setrecursionlimit</strong></a>(...)</dt><dd><tt><a href="#-setrecursionlimit">setrecursionlimit</a>(n)<br> <br> Set the maximum depth of the Python interpreter stack to n. This<br> limit prevents infinite recursion from causing an overflow of the C<br> stack and crashing Python. The highest possible limit is platform-<br> dependent.</tt></dd></dl> <dl><dt><a name="-settrace"><strong>settrace</strong></a>(...)</dt><dd><tt><a href="#-settrace">settrace</a>(function)<br> <br> Set the global debug tracing function. It will be called on each<br> function call. See the debugger chapter in the library manual.</tt></dd></dl> </td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#55aa55"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> <td width="100%"><strong>__stderr__</strong> = <_io.TextIOWrapper name='<stderr>' encoding='UTF-8'><br> <strong>__stdin__</strong> = <_io.TextIOWrapper name='<stdin>' encoding='UTF-8'><br> <strong>__stdout__</strong> = <_io.TextIOWrapper name='<stdout>' encoding='UTF-8'><br> <strong>api_version</strong> = 1013<br> <strong>argv</strong> = ['./make_doc.py']<br> <strong>builtin_module_names</strong> = ('__main__', '_ast', '_codecs', '_functools', '_io', '_locale', '_sre', '_symtable', '_thread', '_warnings', '_weakref', 'builtins', 'errno', 'gc', 'imp', 'marshal', 'posix', 'pwd', 'signal', 'sys', ...)<br> <strong>byteorder</strong> = 'little'<br> <strong>copyright</strong> = 'Copyright (c) 2001-2009 Python Software Foundati...ematisch Centrum, Amsterdam.<font color="#c040c0">\n</font>All Rights Reserved.'<br> <strong>dont_write_bytecode</strong> = False<br> <strong>exec_prefix</strong> = '/usr'<br> <strong>executable</strong> = '/usr/bin/python3'<br> <strong>flags</strong> = sys.flags(debug=0, division_warning=0, inspect=0...ignore_environment=0, verbose=0, bytes_warning=0)<br> <strong>float_info</strong> = sys.floatinfo(max=1.7976931348623157e+308, max_e...epsilon=2.220446049250313e-16, radix=2, rounds=1)<br> <strong>float_repr_style</strong> = 'short'<br> <strong>hexversion</strong> = 50397680<br> <strong>int_info</strong> = sys.int_info(bits_per_digit=30, sizeof_digit=4)<br> <strong>maxsize</strong> = 9223372036854775807<br> <strong>maxunicode</strong> = 1114111<br> <strong>meta_path</strong> = []<br> <strong>modules</strong> = {'__future__': <module '__future__' from '/usr/lib/python3.1/__future__.py'>, '__main__': <module '__main__' from './make_doc.py'>, '_abcoll': <module '_abcoll' from '/usr/lib/python3.1/_abcoll.py'>, '_bisect': <module '_bisect' from '/usr/lib/python3.1/lib-dynload/_bisect.so'>, '_codecs': <module '_codecs' (built-in)>, '_collections': <module '_collections' from '/usr/lib/python3.1/lib-dynload/_collections.so'>, '_compat_pickle': <module '_compat_pickle' from '/usr/lib/python3.1/_compat_pickle.py'>, '_curses': <module '_curses' from '/usr/lib/python3.1/lib-dynload/_curses.so'>, '_functools': <module '_functools' (built-in)>, '_heapq': <module '_heapq' from '/usr/lib/python3.1/lib-dynload/_heapq.so'>, ...}<br> <strong>path</strong> = ['/home/hut/work/ranger', '/usr/lib/python31.zip', '/usr/lib/python3.1', '/usr/lib/python3.1/plat-linux2', '/usr/lib/python3.1/lib-dynload', '/usr/lib/python3.1/site-packages', '/home/hut/.ranger']<br> <strong>path_hooks</strong> = [<class 'zipimport.zipimporter'>]<br> <strong>path_importer_cache</strong> = {'.': None, './make_doc.py': <imp.NullImporter object at 0x7f6a922d69e0>, '/home/hut/.ranger': None, '/home/hut/work/ranger': None, '/home/hut/work/ranger/ranger': None, '/home/hut/work/ranger/ranger/colorschemes': None, '/home/hut/work/ranger/ranger/container': None, '/home/hut/work/ranger/ranger/defaults': None, '/home/hut/work/ranger/ranger/ext': None, '/home/hut/work/ranger/ranger/fsobject': None, ...}<br> <strong>platform</strong> = 'linux2'<br> <strong>prefix</strong> = '/usr'<br> <strong>stderr</strong> = <_io.TextIOWrapper name='<stderr>' encoding='UTF-8'><br> <strong>stdin</strong> = <_io.TextIOWrapper name='<stdin>' encoding='UTF-8'><br> <strong>stdout</strong> = <_io.TextIOWrapper name='<stdout>' encoding='UTF-8'><br> <strong>subversion</strong> = ('CPython', 'tags/r311', '74480')<br> <strong>version</strong> = '3.1.1 (r311:74480, Aug 27 2009, 04:56:37) <font color="#c040c0">\n</font>[GCC 4.4.1]'<br> <strong>version_info</strong> = sys.version_info(major=3, minor=1, micro=1, releaselevel='final', serial=0)<br> <strong>warnoptions</strong> = []</td></tr></table> </body></html>