[Tutor] OO Python: How to change attributes of just one objec t in
alist
alan.gauld@bt.com
alan.gauld@bt.com
Wed, 22 May 2002 15:21:06 +0100
> about it too much but FWIW I would probably give each student an ID
> number and store them all in a dictionary with the ID as the
> key.
This is a good idea.
Someone else suggested using the name as a key - which indirectly
you do now - but that won't work if you get two students with the
same name in the same class (We had two Graham Watsons in my class
at school, and they both joined on the same day mid way thru'
term - we thought the teacher had read the same note twice by
mistake!) Assigning a unique ID and keeping name as an attribute
is much better.
You can even auto generate the ID if you like within
the constructor.
Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld