__builtin__.open on windows NT

Thomas Wouters thomas at xs4all.net
Thu Apr 6 18:28:02 CEST 2000


On Thu, Apr 06, 2000 at 04:01:54PM +0000, Rob Wright wrote:

> i'm new to python, so be prepared...i'm having trouble with open() on
> windows NT.  my script uses the os library and it appears that open()
> in my script is conflicting with an open() function in the os lib.  so
> i tried to use __builtin__.open(), but i get this error "NameError:
> __builtin__"

Well, if you have that conflict, you are doing 'from os import *'.
The easy solution is 'dont do that then'. 'from <module> import *' can be
very bad for your health, for exactly the reason you specify. My advice (and
probably that of most people here ;) would be to change the import into just
'import os' and fix the places where you actually use os.

If you *really* want to use __builtins__, you can: you just have to import
it first ! :-) Remember to do that with 'import __builtins__', or it might
overwrite some of os's variables...

From-armageddon-import-*-ly y'rs,
-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list