comparing elements of a list with a string
Shriphani
shriphanip at gmail.com
Thu Sep 27 06:44:08 EDT 2007
Hello,
Would that mean that if I wanted to append all the (date, time) tuples
to a list, I should do something like:
for file in list_of_backup_files:
some_list.append(file)
By the way I did this:
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)
Regards,
Shriphani Palakodety
More information about the Python-list
mailing list