Newbie pythoner, with bizzare problem
Gordon McMillan
gmcm at hypernet.com
Sat Jul 22 15:56:23 EDT 2000
Paul Prescod wrote:
>Gordon McMillan wrote:
>>
>> >What surprises me, though, is that no one ever
>> >mentions the possibility of writing
>> > inp = __builtin__.open("c:/autoexec.bat",'r')
>>
>> Because __builtin__ is a module and has to be imported. And someone who
>> says
>
>Well yes, but not __builtins__ (with the "s")
>
>Python 1.6a2 (#0, Apr 6 2000, 11:45:12) [MSC 32 bit (Intel)] on win32
>Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>>> __builtins__
><module '__builtin__' (built-in)>
>
Only sometimes. At other times __builtins__ is a dictionary, so
inp = __builtins__.open("...")
would fail, and you'd have to use
inp = __builtins__['open']("....")
-Gordon
More information about the Python-list
mailing list