[Python-Dev] Initialization of builtins (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Sat Oct 10 21:40:34 CEST 2009


Vinay Sajip <vinay_sajip yahoo.co.uk> writes:

In the py3k branch, logging has the line unicode = 'unicode' in dir(builtins)

Why do you do this? In py3k, unicode is always enabled but it's called "str" and the name "unicode" doesn't exist.

to determine the existence of Unicode support. The code in trunk, being 1.5.2 compatible, used

hasattr(types, 'UnicodeType')

Why don't you simply write:

unicode_support = True
try:
    unicode
except NameError:
    unicode_support = False

?



More information about the Python-Dev mailing list