Peculiar Behaviour of __builtins__
Aman Nijhawan
amannijhawan at gmail.com
Thu May 12 19:29:57 EDT 2011
I was trying to call the builtin function min by using
getattr(__builtins__,'min')
This works at the interpretter prompt
However when I called it inside a module that was imported by another module
it fails and gives an attribute error
print getattr(__builtins__,'min')(range(20))
AttributeError: 'dict' object has no attribute 'min'
Also in the interpreter
>>>type(__builtins__)
<type 'module'>
but in my module
print type(__builtins__)
<type 'dict'>
Can anyone help me understand whats going on here?
Thanks
--
Aman Nijhawan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110512/951469cf/attachment.html>
More information about the Python-list
mailing list