Steven> I've been known to monkey-patch builtins in the interactive
    Steven> interpreter and in test code.

Me too.  I use a slightly beefed up dir() funcion which identifies modules
within a package which haven't been imported yet.  Handy for quick-n-dirty
introspection.

    >>> import email
    >>> dir(email)
    ['Charset', 'Encoders', 'Errors', 'FeedParser', 'Generator', 'Header',
    'Iterators', 'LazyImporter', 'MIMEAudio', 'MIMEBase', 'MIMEImage',
    'MIMEMessage', 'MIMEMultipart', 'MIMENonMultipart', 'MIMEText',
    'Message', 'Parser', 'Utils', '[_parseaddr]', '[base64mime]',
    '[charset]', '[encoders]', '[errors]', '[feedparser]', '[generator]',
    '[header]', '[iterators]', '[message]', '[parser]', '[quoprimime]',
    '[test/]', '[utils]', '_LOWERNAMES', '_MIMENAMES', '__all__',
    '__builtins__', '__doc__', '__file__', '__name__', '__package__',
    '__path__', '__version__', '_name', 'base64MIME', 'email', 'importer',
    'message_from_file', 'message_from_string', 'mime', 'quopriMIME', 'sys']

Those names with [...] bracketing the names are submodules or subpackages of
the email package which haven't been imported yet.

Skip
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to