dict tuple update

Batista, Facundo FBatista at uniFON.com.ar
Tue May 6 08:31:02 EDT 2003


#- d = {
#-    0 : ("title0", "", ""),
#-    1 : ("title1", "", None, None, None),
#-    2 : ("title2", "song2", "track1"),
#-    3 : ( None, None, "track0"),
#-    4 : ("title4", "song3", None),
#- }

Try something like this (I'm just writing here, code not tested):

for (key, value) in d.items():
	list = []
	for elem in value:
		if elem == None:
			list.append("")
		else:
			list.append(elem)
	d[key] = tuple(list)


.	Facundo





More information about the Python-list mailing list