[Zope-dev] Python Script
Steve Alexander
steve@cat-box.net
Fri, 23 Feb 2001 12:18:37 +0000
Cyril Elkaim wrote:
>
> for item in container.objectItems():
> if string.strip(item[0]) == image:
> image_width = int(item[1].getProperty("width"))
> image_height = int(item[1].getProperty("height"))
Also, a stylistic point:
In Python, you can use something called "tuple unpacking" or "list
unpacking" that can often help to make your code clearer if you find
yourself referencing the elements of a tuple by index.
Thus, you can rewrite your code, quoted above, as below:
for name,object in container.objectItems():
if string.strip(name) == image:
image_width = int(object.getProperty("width"))
image_height = int(object.getProperty("height"))
--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net