Confused by List behavior

ejbaker_seekonk at ejbaker_seekonk at
Thu Apr 20 07:49:38 EDT 2000

As a python newbie, I entered this script to explore list processing

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
Before you buy.

More information about the Python-list mailing list