Custom Search

Saturday, March 12, 2011

python attributes of sys module

python attributes of sys module

import sys

attr_list = dir(sys)

for attr in attr_list:
str_data = "sys.%s" %(attr)
print "\n", str_data
print "---------------------"
print eval(str_data)

-----------------------OR

import sys
from pprint import pprint
pprint(vars(sys))


OUTPUT
========


sys.__displayhook__
---------------------


sys.__doc__
---------------------
This module provides access to some objects used or maintained by the
interpreter and to functions that interact strongly with the interpreter.

Dynamic objects:

argv -- command line arguments; argv[0] is the script pathname if known
path -- module search path; path[0] is the script directory, else ''
modules -- dictionary of loaded modules

displayhook -- called to show results in an interactive session
excepthook -- called to handle any uncaught exception other than SystemExit
To customize printing in an interactive session or to install a custom
top-level exception handler, assign other functions to replace these.

exitfunc -- if sys.exitfunc exists, this routine is called when Python exits
Assigning to sys.exitfunc is deprecated; use the atexit module instead.

stdin -- standard input file object; used by raw_input() and input()
stdout -- standard output file object; used by the print statement
stderr -- standard error object; used for error messages
By assigning other file objects (or objects that behave like files)
to these, it is possible to redirect all of the interpreter's I/O.

last_type -- type of last uncaught exception
last_value -- value of last uncaught exception
last_traceback -- traceback of last uncaught exception
These three are only available in an interactive session after a
traceback has been printed.

exc_type -- type of exception currently being handled
exc_value -- value of exception currently being handled
exc_traceback -- traceback of exception currently being handled
The function exc_info() should be used instead of these three,
because it is thread-safe.

Static objects:

maxint -- the largest supported integer (the smallest is -maxint-1)
maxsize -- the largest supported length of containers.
maxunicode -- the largest supported character
builtin_module_names -- tuple of module names built into this interpreter
version -- the version of this interpreter as a string
version_info -- version information as a tuple
hexversion -- version information encoded as a single integer
copyright -- copyright notice pertaining to this interpreter
platform -- platform identifier
executable -- pathname of this Python interpreter
prefix -- prefix used to find the Python library
exec_prefix -- prefix used to find the machine-specific Python library
__stdin__ -- the original stdin; don't touch!
__stdout__ -- the original stdout; don't touch!
__stderr__ -- the original stderr; don't touch!
__displayhook__ -- the original displayhook; don't touch!
__excepthook__ -- the original excepthook; don't touch!

Functions:

displayhook() -- print an object to the screen, and save it in __builtin__._
excepthook() -- print an exception and its traceback to sys.stderr
exc_info() -- return thread-safe information about the current exception
exc_clear() -- clear the exception state for the current thread
exit() -- exit the interpreter by raising SystemExit
getdlopenflags() -- returns flags to be used for dlopen() calls
getprofile() -- get the global profiling function
getrefcount() -- return the reference count for an object (plus one :-)
getrecursionlimit() -- return the max recursion depth for the interpreter
getsizeof() -- return the size of an object in bytes
gettrace() -- get the global debug tracing function
setcheckinterval() -- control how often the interpreter checks for events
setdlopenflags() -- set the flags to be used for dlopen() calls
setprofile() -- set the global profiling function
setrecursionlimit() -- set the max recursion depth for the interpreter
settrace() -- set the global debug tracing function


sys.__egginsert
---------------------
2

sys.__excepthook__
---------------------


sys.__name__
---------------------
sys

sys.__package__
---------------------
None

sys.__plen
---------------------
13

sys.__stderr__
---------------------
', mode 'w' at 0x7f907428b1e0>

sys.__stdin__
---------------------
', mode 'r' at 0x7f907428b0c0>

sys.__stdout__
---------------------
', mode 'w' at 0x7f907428b150>

sys._clear_type_cache
---------------------


sys._current_frames
---------------------


sys._getframe
---------------------


sys.api_version
---------------------
1013

sys.argv
---------------------
['test.py']

sys.builtin_module_names
---------------------
('__builtin__', '__main__', '_ast', '_bisect', '_codecs', '_collections', '_functools',
'_hashlib', '_locale', '_random', '_socket', '_sre', '_ssl', '_struct', '_symtable',
'_warnings', '_weakref', 'array', 'binascii', 'cPickle', 'cStringIO', 'errno',
'exceptions', 'fcntl', 'gc', 'grp', 'imp', 'itertools', 'marshal', 'math', 'operator',
'posix', 'pwd', 'select', 'signal', 'spwd', 'strop', 'sys', 'syslog', 'thread', 'time',
'unicodedata', 'xxsubtype', 'zipimport', 'zlib')

sys.byteorder
---------------------
little

sys.call_tracing
---------------------


sys.callstats
---------------------


sys.copyright
---------------------
Copyright (c) 2001-2010 Python Software Foundation.
All Rights Reserved.

Copyright (c) 2000 BeOpen.com.
All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.

Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved.

sys.displayhook
---------------------


sys.dont_write_bytecode
---------------------
False

sys.exc_clear
---------------------


sys.exc_info
---------------------


sys.exc_type
---------------------
None

sys.excepthook
---------------------


sys.exec_prefix
---------------------
/usr

sys.executable
---------------------
/usr/bin/python

sys.exit
---------------------


sys.flags
---------------------
sys.flags(debug=0, py3k_warning=0, division_warning=0, division_new=0, inspect=0,
interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0,
ignore_environment=0, tabcheck=0, verbose=0, unicode=0, bytes_warning=0)

sys.float_info
---------------------
sys.floatinfo(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308,
min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53,
epsilon=2.2204460492503131e-16, radix=2, rounds=1)

sys.getcheckinterval
---------------------


sys.getdefaultencoding
---------------------


sys.getdlopenflags
---------------------


sys.getfilesystemencoding
---------------------


sys.getprofile
---------------------


sys.getrecursionlimit
---------------------


sys.getrefcount
---------------------


sys.getsizeof
---------------------


sys.gettrace
---------------------


sys.hexversion
---------------------
33949168

sys.maxint
---------------------
9223372036854775807

sys.maxsize
---------------------
9223372036854775807

sys.maxunicode
---------------------
1114111

sys.meta_path
---------------------
[]

sys.modules
---------------------
{'copy_reg': , 'encodings': , 'site': , '__builtin__': , '__main__': ,
'encodings.encodings': None, 'abc': , 'posixpath': , 'errno': ,
'encodings.codecs': None, '_abcoll': , 'types': , '_codecs': , '_warnings': ,
'genericpath': , 'stat': , 'zipimport': , 'encodings.__builtin__': None,
'warnings': , 'UserDict': , 'encodings.utf_8': , 'sys': , 'codecs': , 'os.path': ,
'sitecustomize': , 'signal': , 'apport_python_hook': , 'linecache': , 'posix': ,
'encodings.aliases': , 'exceptions': , 'os': }

sys.path
---------------------
['/home/test/Desktop/test',
'/usr/local/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg',
'/usr/local/lib/python2.6/dist-packages/virtualenv-1.5.1-py2.6.egg',
'/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '
/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload',
'/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL',
'/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6',
'/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0',
'/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode',
'/usr/local/lib/python2.6/dist-packages']

sys.path_hooks
---------------------
[]

sys.path_importer_cache
---------------------
{'/usr/lib/python2.6/lib-tk': None,
'/usr/local/lib/python2.6/dist-packages/virtualenv-1.5.1-py2.6.egg': None,
'/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode': None, 'test.py': ,
'/usr/lib/pymodules/python2.6/gtk-2.0': None, '/usr/lib/python2.6/plat-linux2': None,
'/usr/lib/python2.6/lib-old': , '/usr/lib/python2.6/dist-packages/gtk-2.0': None,
'/usr/lib/python2.6/dist-packages/PIL': None, '
/usr/local/lib/python2.6/dist-packages': None, '/usr/lib/python2.6/': None,
'/usr/local/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg': ,
'/usr/lib/python2.6/dist-packages': None,
'/usr/lib/python2.6/dist-packages/gst-0.10': None,
'/usr/lib/pymodules/python2.6': None, '/usr/lib/python2.6': None,
'/usr/lib/python2.6/lib-dynload': None, '/usr/lib/python2.6/encodings': None}

sys.platform
---------------------
linux2

sys.prefix
---------------------
/usr

sys.py3kwarning
---------------------
False

sys.pydebug
---------------------
False

sys.setcheckinterval
---------------------


sys.setdlopenflags
---------------------


sys.setprofile
---------------------


sys.setrecursionlimit
---------------------


sys.settrace
---------------------


sys.stderr
---------------------
', mode 'w' at 0x7f907428b1e0>

sys.stdin
---------------------
', mode 'r' at 0x7f907428b0c0>

sys.stdout
---------------------
', mode 'w' at 0x7f907428b150>

sys.subversion
---------------------
('CPython', 'tags/r265', '79063')

sys.version
---------------------
2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3]

sys.version_info
---------------------
(2, 6, 5, 'final', 0)

sys.warnoptions
---------------------
[]


No comments:

Post a Comment