[BangPypers] magic in datetime module?
Anand Chitipothu
anandology at gmail.com
Fri Apr 3 08:05:53 CEST 2009
2009/4/3 Anand Chitipothu <anandology at gmail.com>:
> I'm noticed a strange Import error in some web.py template. I nailed
> down the problem to the following python code.
>
> __builtins__ = {}
>
> import datetime
> now = datetime.datetime.utcnow()
> print now.strftime("%m %Y")
>
> It fails with the following error.
>
> Traceback (most recent call last):
> File "foo.py", line 6, in <module>
> print now.strftime("%m %Y")
> KeyError: '__import__'
>
> Any experts around for explaining this behavior?
Another strange behavior:
when run as script, it fails at the last line and when run tried in
interpreter, it fails at the import.
More information about the BangPypers
mailing list