Class subscripting

Ronny Mandal ronnyma at math.uio.no
Fri Feb 17 19:09:22 EST 2006


Assume we have a class Foo, and instance called bar.

a variable called baz1 has the value 3.0, baz2 is uninitialized

Is there a way of reflecting the variable with such syntax:

print bar[<var_index>], where var_index is a number representing
internal index.

bar[<var_index>] = 4.2. #Setting baz2 to 4.2

Thanks and regards,

Ronny Mandal



More information about the Python-list mailing list