[BangPypers] magic in datetime module?

Anand Chitipothu anandology at gmail.com
Fri Apr 3 07:59:32 CEST 2009


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?


More information about the BangPypers mailing list