[Tutor] eval weirdness
Gregor Lingl
glingl@aon.at
Sat Nov 30 01:10:02 2002
gp@pooryorick.com schrieb:
>Hi,
>
>It appears that the following code causes __builtins__.__dict__ to be
>assigned to self.names. Can anyone help me understand what is going on
>here?
>
>
>class testclass:
> def __init__(self):
> self.names = {}
> eval('5 + 5', self.names, self.names)
> print self.names
>
>if __name__ == '__main__':
> testclass()
>
>
>
Hmmm, strange! I' curious, too!
BTW:
>>> what = __builtins__.__dict__['help']
>>> what
Type help() for interactive help, or help(object) for help about object.
>>> type(what)
<type 'instance'>
>>>
Which class is what an instance of?
Gregor
>
>Thanks,
>
>Poor Yorick
>gp at pooryorick.com
>
>
>--------------------------------------------------------------------
>mail2web - Check your email from the web at
>http://mail2web.com/ .
>
>
>
>_______________________________________________
>Tutor maillist - Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>
>