Jump to content
  • Advertisement
Sign in to follow this  
abseeley

Python: Using only part of a returned tuple

This topic is 3668 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Quick question probably with a quick answer. Im working on a simple steganography project (hiding a message in a picture) im using PIL to return pixel values. Im using quick unpack to sift through so the function would be called like so: getpixel(myPixelHandle) now this returns a 3 size tuple with the R G and B values so the raw return looks like this: (255, 50, 199) So to quick unpack im doing it like this: valRed, valGreen, valBlue = getpixel(myPixelHandle) This way my three val's each are equal to there corresponding values. However I am currently just trying to modify the red value of every pixel. But there is only that one function for getting pixel data. Is there anyway that I can quick unpack and just get one value return? Or do I have to do something like: myTuple = getpixel(myPixelHandle) valRed = myTuple(0) or even? valRed, NULLval, NULLval = getpixel(myPixelHandle) so Nullval would just be variables i dont use? Any answers?

Share this post


Link to post
Share on other sites
Advertisement
The function is evaluated first, so you can go ahead and get an index directly on that...

valRed = getpixel(myPixelHandle)[0]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!