(no subject)
mis6 at pitt.edu
mis6 at pitt.edu
Fri Jan 31 14:41:09 EST 2003
Subject: adding to __builtins__
Consider the following script (I need it under Python 2.2, where True and
False are undefined):
--- begin truefalse.py --
__builtins__.True=1
__builtins__.False=0
print True,False
--- end truefalse.py --
It works:
$ python truefalse.py
1 0
However, if I import the script I have an AttributeError:
python
Python 2.2 (#1, Apr 12 2002, 15:29:57)
[GCC 2.96 20000731 (Red Hat Linux 7.2 2.96-109)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import truefalse
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "truefalse.py", line 3, in ?
__builtins__.True=1
AttributeError: 'dict' object has no attribute 'True'
What's happening and is there a workaround ?
TIA,
Michele
More information about the Python-list
mailing list