x[i] as loop variable

Gerrit Holl gerrit at nl.linux.org
Thu Oct 23 13:44:56 EDT 2003


Hi,

PEP 289 says:
(Loop variables may also use constructs like x[i] or x.a; this form may be deprecated.)

What is this about? I found this:
19:41:33:232:35 >>> a=Test()
19:41:37:232:36 >>> for a.foo in L: print a.foo
19:41:37:232:36 ...
<__main__.Test object at 0x4018516c>
<__main__.Test object at 0x401854cc>
<__main__.Test object at 0x401854ac>
19:41:49:232:37 >>> for obj in L: print obj.foo,
19:41:49:232:37 ...
bar baz bax

What is the use of this? When should I use it? Why 'may it be deprecated'?
I don't see this construct in the Language Reference. I looked at:
http://www.python.org/dev/doc/devel/ref/for.html

yours probably,
Gerrit.

-- 
 that he caught run away from him, then shall he swear
to the owners of the slave, and he is free of all blame.
          -- 1780 BC, Hammurabi, Code of Law
-- 
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Kom in verzet tegen dit kabinet:
	http://www.sp.nl/





More information about the Python-list mailing list