[Pythonmac-SIG] Where is the sys module?

Skip Montanaro skip@pobox.com
Sun, 13 Apr 2003 17:37:59 -0500


    Paul> The O'Reilly "Learning Python" tells me I should be able to get
    Paul> the sys module, and all its attributes, by typing

    Paul>     dir(sys)

    Paul> in the interactive Python interpreter. It doesn't work (default OS
    Paul> 10.2 installation of Python 2.2):

I think perhaps you're misreading something.  "sys" is a module, so to use
it you have to import it into the current namespace.  Try this instead:

    >>> import sys
    >>> dir(sys)
    ['__displayhook__', '__doc__', '__excepthook__', '__name__',
    '__stderr__', '__stdin__', '__stdout__', '_getframe', 'api_version',
    'argv', 'builtin_module_names', 'byteorder', 'callstats', 'copyright',
    'displayhook', 'exc_clear', 'exc_info', 'exc_type', 'excepthook',
    'exec_prefix', 'executable', 'exit', 'exitfunc', 'getdefaultencoding',
    'getdlopenflags', 'getfilesystemencoding', 'getrecursionlimit',
    'getrefcount', 'hexversion', 'maxint', 'maxunicode', 'meta_path',
    'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform',
    'prefix', 'ps1', 'ps2', 'setcheckinterval', 'setdlopenflags',
    'setprofile', 'setrecursionlimit', 'settrace', 'stderr', 'stdin',
    'stdout', 'version', 'version_info', 'warnoptions'] 

Skip