How to force built-in commands over imported.
Gerhard Häring
gerhard.haering at opus-gmbh.net
Wed Sep 4 10:55:05 EDT 2002
Maurice van de Rijzen wrote:
> Dear all.
> I'm a newbie on the field of python, therefore the answer to my question
> may be simple.
> There is a built-in commans called open(fileName). There is also a
> open() command in the os-module open which needs more than the fileName.
> Originally I didn't import the os-module and everything worked fine.
> However, when I imported the os-module I received an error that open
> needed more arguments. How can I force to take the built-in open()
> instead of the open() in the os-module.
The technical answer is to use __builtins__["open"].
A good advice is to avoid the use of "from ... import *" in most cases.
Just "import os", then use the desired function by prefixing it with the
module name, like "os.open".
-- Gerhard
More information about the Python-list
mailing list