Confused by List behavior

ejbaker_seekonk at my-deja.com ejbaker_seekonk at my-deja.com
Thu Apr 20 13:49:38 CEST 2000


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?


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list