[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



On Fri, Jun 19, 2009 at 2:49 PM, Toni Alatalo<antont@xxxxxxxxxxxxx> wrote:
> On Thu, 18 Jun 2009, René Dudfield wrote:
>
>> This is useful if you want to unpack to r,g,b and not r,g,b,a
>>>>>
>>>>> c = Color(1,2,3,4)
>>>>> c.set_length(3)
>>>>> r,g,b = c
>
> what about:
>
> r, g, b = c.rgb

yeah, that's a very cool way to access it.  It's what you can do with
newer vector languages (eg glsl/cg etc).  They call them swizzle
operators.  Maybe after 1.9.0.

As you mention backwards compatibility is quite important...
set_length will mainly be for backwards compat... rather than breaking
a few games which are packaged in 50 different distros, and then
having them not upgrade pygame for ages because it breaks a few
games... which is what slowed down uptake for pygame 1.8.1.  So this
time I'm trying to make sure games/apps included in distros are not
broken by the release - at least trying not to break as many as
possible.



cu,