En Thu, 27 Sep 2007 07:44:08 -0300, Shriphani <[EMAIL PROTECTED]>  
escribi�:

> def listAllbackups(filename):
>       list_of_backups = glob(home+'/Desktop/backupdir/*%s*'%filename)
>       for element in list_of_back:
>               if element.find(file) != -1:
>                       date_components = element.split('-')[-4:-1]
>                       date = str(date_components[0]) + ":" + 
> str(date_components[1]) +
> ":" + str(date_components[2])
>                       time = element.split('-')[-1]
>                       yield (date, time)
> print listAllbackups('fstab')
>
>
> I ran it in the terminal and I got:
>
> <generator object at 0x81ed58c>
>
> Why does it do that and not just print out all the values of (date,
> time)

Because listAllbackups is a generator function: each time someone asks it  
the next value, it runs until the "yield" statement, and pauses. Next time  
execution continues from the same point.
You have to iterate over it. Try:

for date,time in listAllbackups('fstab'):
     print date,time

or

items = list(listAllbackups('fstab'))
print items

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to