Reputation: 2203
How do you explicitly access name in Python's built in scope?
One situation where I ran in to this was a in module, say called foo, which happened to have an open function. In another module foo's open function would be accessible as foo.open which works well. In foo itself though, open blocks the built in open. How can you access the built in version of a name like open explicitly?
I am aware it is probably practically bad idea to block any built in name, but I am still curious to know if there is a way to explicitly access the built in scope.
Upvotes: 11
Views: 2125
Reputation: 90221
Use __builtin__
.
def open():
pass
import __builtin__
print open
print __builtin__.open
... gives you ...
<function open at 0x011E8670>
<built-in function open>
Upvotes: 12