[Python-Dev] Initialization of builtins (original) (raw)
Vinay Sajip vinay_sajip at yahoo.co.uk
Sat Oct 10 21:31:07 CEST 2009
- Previous message: [Python-Dev] PEP about sys.implementation and implementation specific user site directory
- Next message: [Python-Dev] Initialization of __builtins__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm not top-posting, but gmane is giving me a hard time :-(
In the py3k branch, logging has the line
_unicode = 'unicode' in dir(builtins)
to determine the existence of Unicode support. The code in trunk, being 1.5.2 compatible, used
hasattr(types, 'UnicodeType')
I wanted to eliminate the types import and modernise the trunk code a bit, so I copied the py3k line to the trunk version of logging. It didn't work as expected! So I added the line
print dir(builtins)
in logging fairly early on (though not the very first line - just after the
date = ...
line. Here's what I got with 2.7a0 and 2.6.1:
Python 2.7a0 (trunk:75292M, Oct 9 2009, 09:21:05) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
import logging ['class', 'cmp', 'contains', 'delattr', 'delitem', 'doc', 'eq', 'format', 'ge', 'getattribute', 'getitem', 'gt', 'hash', 'init', 'iter', 'le', 'len', 'lt', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'setitem', 'sizeof', 'str', 'subclasshook', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
ActivePython 2.6.1.1 (ActiveState Software Inc.) based on Python 2.6.1 (r261:67515, Dec 5 2008, 13:58:38) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
import logging ['class', 'cmp', 'contains', 'delattr', 'delitem', 'doc', 'eq', 'format', 'ge', 'getattribute', 'getitem', 'gt', 'hash', 'init', 'iter', 'le', 'len', 'lt', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'setitem', 'sizeof', 'str', 'subclasshook', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
However, if I just do
dir(builtins)
in the interactive prompt, I get the whole shebang.
Excuse my ignorance, but how come?
Regards,
Vinay Sajip
- Previous message: [Python-Dev] PEP about sys.implementation and implementation specific user site directory
- Next message: [Python-Dev] Initialization of __builtins__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]