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

Re: [pygame] how hexcolour arrays works?



hi again



Paulo Silva schrieb:
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



# you cannot say how many entries the list will have at creation, just create a empty list and add the values
li = []
# if the values are know in the beginning: li = [vlaue1, value2, ...]

# some code

li.append( value1)

# some code

li.insert(pos, value2) # pos is the possition in the list


What type vlaue1 and value2 are is not important, so value1 could be an int, value2 could be a string or a float or whatever
and yes, python is alot about readbility, so please dont use ';'

here the guidelines: http://www.python.org/dev/peps/pep-0008/
(it will you take some effort and time to master all guidelines, but I think it is worth it )

scrolling doesnt hurt, if you dont see enough use an editor with splitted windows.

~DR0ID