python script looping
Hello All, I am getting Error Type: TypeError Error Value: unsliceable object when i ran this python script yymmdd='040712' for i in container.pictures.objectValues(['Image']): if yymmdd==i.id[5:11]: return i.title the pictures is the name of folder that contain the images but i want the script to be in the same container as the pictures. thanks
Somethimes the id is not a property but a method that return the id, try to use the method getId() []'s Hamzat Kamal writes:
Hello All,
I am getting
Error Type: TypeError Error Value: unsliceable object
when i ran this python script
yymmdd='040712' for i in container.pictures.objectValues(['Image']): if yymmdd==i.id[5:11]: return i.title
the pictures is the name of folder that contain the images but i want the script to be in the same container as the pictures.
thanks
From: Hamzat Kamal
I am getting Error Type: TypeError Error Value: unsliceable object
when i ran this python script
yymmdd='040712' for i in container.pictures.objectValues(['Image']): if yymmdd==i.id[5:11]: return i.title
the pictures is the name of folder that contain the images but i want the script to be in the same container as the >pictures.
I think you want something like: yymmdd='040712' for i in container.picture.objectItems(['DTML Method']): sid = str(i[0]) if yymmdd==sid[5:11]: return i[1].title_or_id() However, this will only return the first instance where the id of the file object matches the contents of yymmdd. If you want to return all matches then you need something like: idlist=[] yymmdd='040712' for i in container.picture.objectItems(['DTML Method']): sid = str(i[0]) if yymmdd==sid[5:11]: idlist.append( i[1].title_or_id() ) return idlist HTH Jonathan
Thanks it works. At 09:31 AM 7/13/2004 -0400, you wrote:
From: Hamzat Kamal
I am getting Error Type: TypeError Error Value: unsliceable object
when i ran this python script
yymmdd='040712' for i in container.pictures.objectValues(['Image']): if yymmdd==i.id[5:11]: return i.title
the pictures is the name of folder that contain the images but i want the script to be in the same container as the >pictures.
I think you want something like:
yymmdd='040712' for i in container.picture.objectItems(['DTML Method']): sid = str(i[0]) if yymmdd==sid[5:11]: return i[1].title_or_id()
However, this will only return the first instance where the id of the file object matches the contents of yymmdd. If you want to return all matches then you need something like:
idlist=[] yymmdd='040712' for i in container.picture.objectItems(['DTML Method']): sid = str(i[0]) if yymmdd==sid[5:11]: idlist.append( i[1].title_or_id() )
return idlist
HTH
Jonathan
participants (3)
-
Hamzat Kamal -
Jonathan Hobbs -
Marcos Iuato