function in a function accessing vars
Dustan
DustanGroups at gmail.com
Wed Jun 6 07:52:52 EDT 2007
On Jun 6, 6:40 am, "Jorgen Bodde" <jorgen.maill... at gmail.com> wrote:
> Hi Diez,
>
> Thanks, I thought it worked similar to C++ where a higher compound
> could access a lower section.
It can 'access a lower section'; what it can't do is *change* that
'lower section'; in your example case with an int, this matters
because ints are immutable. Lists, on the other hand, are mutable. You
can *access* the methods of the list that mutate it. You're always
working with the same list, but it has different contents when you
mutate it.
> But as it is not straight forward, I
> think it is better to embed the functionality inside a class, and make
> it a member variable .. now why didn't I think of that ;-)
More information about the Python-list
mailing list