> >>> del __builtins__
> >>> dir()
> ['__builtins__', '__doc__', '__name__', 'keyword']
>
> Didn't work.  Nothing happens.  But the keyword namespace is easy to get rid 
> of:

<wizard  type="smartypants">
<comment>

Wrongo, buddy boy!

Something *does* happen when you delete __builtins__.

It sticks around *as a dictionary* named __builtins__, but you've
purged it from the namespace *as a module* -- which is what allowed
dir to treat it as such, and return just a list.

Look below:

>>> ============= RESTART ==============
>>> __builtins__
<module '__builtin__' (built-in)>

>>> type(__builtins__)
<type 'module'>

>>> del __builtins__
>>> type(__builtins__)
<type 'dict'>

>>> del __builtins__
>>> type(__builtins__)
<type 'dict'>

Now if you go dir(__builtins__), it'll just give you the namespace of
a regular dictionary, and if you put __builtins__ on the command line
and press enter, you'll get a dump of that dictionary's contents (an
invocation of its __repr__ method).

</comment>
</wizard>

Thanks a lot Smartypants.  I'm sure we'll be seeing *you* here again.

Kirby
_______________________________________________
Edu-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/edu-sig

Reply via email to