[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Color, unpacking to r,g,b and r,g,b,a - ValueError: too many values to unpack
Hi,
Personally, I think all functions should return 4 values. Most code like:
r,g,b = #blah(...)
can be pretty easily retrofitted like:
try:r,g,b = #blah(...)
except:r,g,b,a = #blah(...)
I actually anticipated this problem, so most of my code looks like:
color = #blah(...)
#use color[0],color[1],color[2]
As you can see, whether color[3] exists is irrelevant. When I need alpha, I check the docs to find which function(s) to use.
However, for all functions in the future, I think it's best to err on the side of sending the user more information rather than less...
Ian
- References:
- [pygame] Color, unpacking to r,g,b and r,g,b,a - ValueError: too many values to unpack
- Re: [pygame] Color, unpacking to r,g,b and r,g,b,a - ValueError: too many values to unpack
- Re: [pygame] Color, unpacking to r,g,b and r,g,b,a - ValueError: too many values to unpack
- Re: [pygame] Color, unpacking to r,g,b and r,g,b,a - ValueError: too many values to unpack
- Re: [pygame] Color, unpacking to r,g,b and r,g,b,a - ValueError: too many values to unpack
- Re: [pygame] Color, unpacking to r,g,b and r,g,b,a - ValueError: too many values to unpack
- Re: [pygame] Color, unpacking to r,g,b and r,g,b,a - ValueError: too many values to unpack
- Prev by Author:
Re: [pygame] Nehe Lesson 19
- Next by Author:
Re: [pygame] update() weirdness
- Previous by thread:
Re: [pygame] Color, unpacking to r,g,b and r,g,b,a - ValueError: too many values to unpack
- Next by thread:
Re: [pygame] Color, unpacking to r,g,b and r,g,b,a - ValueError: too many values to unpack
- Index(es):