Reputation: 906
I find a strange statement when I'm reading PIL document.
In 1.1.6 and later, load returns a pixel access object that can be used to read and modify pixels. The access object behaves like a 2-dimensional array, so you can do:
pix = im.load() print pix[x, y] pix[x, y] = value
What does pix[x, y]
mean here? It's not slicing syntax because ,
used rather than :
.
Upvotes: 8
Views: 1987
Reputation: 97641
pix[x, y]
is the same as
t = x, y
pix[t]
or
t = (x, y)
pix[t]
or
pix[(x, y)]
What you're seeing is a tuple literal inside an item-getting expression, in the same way that I can nest other expressions such as l[1 if skip else 0]
Upvotes: 13