> # I have some lists
> GameLogic.varList0=[1,1,1,1]
> GameLogic.varList1=[1,1,1,1]
> GameLogic.varList3=[1,1,1,1]
Pythonically:
GameLogic.varLists = [[1,1,1,1],
[1,1,1,1],
[1,1,1,1]]
> # But I want the assignment
> # to be based on variables
> LIST=1
John,
On Mon, 28 Feb 2005 06:05:44 -0800 (PST), John Christian
<[EMAIL PROTECTED]> wrote:
> a python 2.3 noob asks:
>
> # I have some lists
> GameLogic.varList0=[1,1,1,1]
> GameLogic.varList1=[1,1,1,1]
> GameLogic.varList3=[1,1,1,1]
>
> # I want to change specific list elements
> GameLogic.varLi
John Christian wrote:
# But I want the assignment
# to be based on variables
LIST=1
POSITION=2
GameLogic.varList$LIST[$POSITION]=0
>>> help(getattr)
Help on built-in function getattr:
getattr(...)
getattr(object, name[, default]) -> value
Get a named attribute from an object; getattr(x, 'y
a python 2.3 noob asks:
# I have some lists
GameLogic.varList0=[1,1,1,1]
GameLogic.varList1=[1,1,1,1]
GameLogic.varList3=[1,1,1,1]
# I want to change specific list elements
GameLogic.varList0[2]=0
print GameLogic.varList0
[1,1,0,1]
# But I want the assignment
# to be based on variables
LIST=1
PO