Multiplying a tuple by a scalar

devoured elysium picture devoured elysium · Nov 23, 2009 · Viewed 66.9k times · Source

I have the following code:

print(img.size)
print(10 * img.size)

This will print:

(70, 70)
(70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70)

I'd like it to print:

(700, 700)

Is there any way to do this without having to write:

print(10 * img.size[0], 10 * img.size[1])

PS: img.size is a PIL image. Dunno if that matters anything in this case.

Answer

Hannes Ovrén picture Hannes Ovrén · Nov 23, 2009

Might be a nicer way, but this should work

tuple([10*x for x in img.size])