[BangPypers] magic in datetime module?
Anand Chitipothu
anandology at gmail.com
Fri Apr 3 08:18:45 CEST 2009
Let me re-write the code to remove the confusion between command-line
and interpreter modes.
import datetime
now = datetime.datetime.utcnow()
__builtins__ = {}
print now.strftime("%m %Y")
Why should this fail?
I did some hack to see who is calling import.
import datetime
now = datetime.datetime.utcnow()
def ximport(*a, **kw):
print a, kw
raise Exception
__builtins__ = {'__import__': ximport}
f = now.strftime
print f("%m %Y")
It fails when f is called.
Traceback (most recent call last):
File "x.py", line 11, in <module>
print f("%m %Y")
File "x.py", line 7, in ximport
raise Exception
Exception
Any clues?
More information about the BangPypers
mailing list