[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] how hexcolour arrays works?



Dr0id, thanks! your code resulted as i wanted, but...

::> This 'a = []*8  ' does not what you expect. See documentation.

which documentation? where?



::> a = [0x883746, 0xA88721, 0xBDE87A, 0xEE875F, 0xFE98A1, 0x334836,
0x374838, 0xAAB398]

Is it the only way for defining numeral (float and integer) arrays in python?
What i wanted is:
. define the size of the array before using it - just like 'dim a[8]'
works on sdlBasic, and 'a_st=[""]*8' works so fine with strings on
Python
. being able to put values inside the array when and where i want,
just like a[5]=0x403304



::> http://www.diveintopython.org/native_data_types/lists.html

It's exactly what i want to avoid... this example is only about
strings (and i'm looking for numerals like integer and float
examples), and are mostly about array concatenation, what i'm really
avoiding now...

thanks again! :-)

-----------------------------------------------------------


On Mon, Jul 28, 2008 at 12:12 PM, Paulo Silva <nitrofurano@xxxxxxxxx> wrote:
> running python as direct mode also provides me the same error?
>
> Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
> [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> a=[]*8
>>>> a[0]=0xFF0000
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> IndexError: list assignment index out of range
>>>>
>
> --------------------------------
>
>
>
> On Mon, Jul 28, 2008 at 12:03 PM, Paulo Silva <nitrofurano@xxxxxxxxx> wrote:
>> thanks, but i found nothing there... :-(
>>
>> ----------------
>>
>> On Mon, Jul 28, 2008 at 11:56 AM, Noah Kantrowitz <noah@xxxxxxxxxxxxxx> wrote:
>>> Paulo Silva wrote:
>>>>
>>>> Hi, i'm having problems on defining a hexcolour array - weird is i
>>>> never have this kind of problem when defining a string array in the
>>>> same way...
>>>> This may look as a very naive mistake, but i got really stuck, since
>>>> even from google searches i can't get any help...
>>>> Thanks a lot in advance... :-)
>>>
>>> http://diveintopython.org/native_data_types/lists.html
>>>
>>> --Noah
>>>
>>>
>>
>