Confused by List behavior

Moshe Zadka moshez at math.huji.ac.il
Thu Apr 20 15:34:07 CEST 2000


On Thu, 20 Apr 2000 ejbaker_seekonk at my-deja.com wrote:

> As a python newbie, I entered this script to explore list processing
> behaviours.
> 
> yy = dir()
> for element in yy:
>   print element
> 
> for element in yy:
>   print dir(element)
> 
> The first 'for' loop works as expected. It returns,
> ['__builtins__', '__doc__', '__name__'].
> 
> The second loop, however, returns three empty lists. For the life of
> me, I can't understand that. Becauese, if I type 'dir(__builtins__)',
> in a script, I get all of the elements of __builtins__.
> 
> Can anyone explain this?

Hint: what happens if you type dir('__builtins__')?

thank-god-this-isn't-tcl-ly y'rs, Z.
--
Moshe Zadka <mzadka at geocities.com>. 
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com





More information about the Python-list mailing list