SV: A little disappointed so far

Damien Metzler dmetler.nospam at partner.auchan.fr
Mon May 19 11:28:25 EDT 2003


>>2) assignments in test-expressions - eg:
>>while i++ < 10:
>>or
>>if row = cursor.fetchone() != None:
> 
> 
> The first of these is often (not always) better written as a for loop in 
> Python. These days it is often worthwhile looking at any while loop and 
> considering whether to use a for loop and an iterator instead.
> 
> The second also looks like it should end up being a for loop:
> 
>     for row in cursor:
>        ...
> 
> 

I you do this while reading long files, you put all your file in memory 
then ?

what i miss for me is a thing like

while (row=cursor.fetchrow) :
     do my stuffs with row

Instead of doing

cursor.first()
for i in range(cursor.count()):
    row=cursor.getRow()
    do my stuffs with row







More information about the Python-list mailing list