murph hat geschrieben:nur um ein Programm zu beenden, sys zu importieren
Hi murph!
sys ist immer da. Es ist direkt ins Python eingebaut. Es ist nur nicht im Namensraum. Bei ``import sys`` muss Python nicht extra auf die Festplatte zugreifen.
Code: Alles auswählen
>>> import sys
>>> sys
<module 'sys' (built-in)>
>>> import shutil
>>> shutil
<module 'shutil' from 'C:\Python24\lib\shutil.pyc'>
>>> sys.builtin_module_names
('__builtin__', '__main__', '_bisect', '_codecs', '_codecs_cn',
'_codecs_hk', '_codecs_iso2022', '_codecs_jp', '_codecs_kr',
'_codecs_tw', '_csv', '_heapq', '_hotshot', '_locale', '_multibytecodec',
'_random', '_sre', '_subprocess', '_symtable', '_weakref', '_winreg',
'array', 'audioop', 'binascii', 'cPickle', 'cStringIO', 'cmath', 'collections',
'datetime', 'errno', 'exceptions', 'gc', 'imageop', 'imp', 'itertools',
'marshal', 'math', 'md5', 'mmap', 'msvcrt', 'nt', 'operator', 'parser',
'regex', 'rgbimg', 'sha', 'signal', 'strop', 'struct', 'sys', 'thread', 'time',
'xxsubtype', 'zipimport')
>>>
Fazit: sys importieren hat keinerlei Nachteile.
lg
Gerold