[BangPypers] magic in datetime module?
Anand Chitipothu
anandology at gmail.com
Fri Apr 3 09:01:40 CEST 2009
> web.py is a great framework, but this is bad coding for sure.
> I guess you need to do some hack like,
>
> oldbuiltins=__builtins__
> __builtins__ = {}
>
> Then before calling code that breaks,
> __builtins__ = oldbuiltins
>
> <call breaking code here>
>
> But this is damn ugly and if it were me, I would investigate other
> options whch doesn't force me to put __builtins__ to {} in my
> code. I don't know details enough to advise you on this
> specifically in this case.
Not really!
What it does is something like this:
code = generate_code(template)
env = {'__builtins__': custom_builtins}
exec(code, env)
More information about the BangPypers
mailing list