try 'for in' as in:
def func(aref):
return [aref] * 3
a = 'else!'
for b in func(a):
print 'something....' + b
#David
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 26, 2002 4:29 AM
To: [EMAIL PROTECTED]
Subject: loop control in Python
The range() function a nice one to create a list and enumerate it with a
'foreach'.
But it creates a static list and enumerates it.
The spice of 'for' of perl, java, C and ... is that you haven't know the
list before you enumerate it.
It is frustrate me when i tried :
while b = func(a):
print something....
assignment isn't posseible in while.
In Perl, or in C i can write
for(a=12, b=a+1, c=&p, d=&a, d=func(kjlkjl), ... ; comp(d, a); a++, b++,
c++, d++) {
}
But not in Python.
These occassions i turn to perl.
How handle it in python?
I know it is a different language, but how can i do it in python?
How i have to thinking ?
>>Some problems could arise with extended abilities of C/C++
>> for (i = <init>; <cond>; <incr>)
>> {
>> <smth>
>> }
E-Mail: [EMAIL PROTECTED]
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs