[Tutor] Poor style to use list as "array"?
Noufal Ibrahim
noufal at nibrahim.net.in
Sun Jul 5 21:30:58 CEST 2009
Angus Rodgers wrote:
[..]
>
> This feels like a bit of a cheat, as if I am trying to program in
> Python as if it were some other more familiar language. Should I
> have coded this differently?
I can't offer anything concrete but here are some things that occur to
me at a glance.
0. You can try to use the collections module in 2.6 (especially the
namedtuple object which gives you access to things through attributes as
well as through order.
1. You have 3 lists (denom, plural and count) which you will iterate
through in lockstep as far as I can tell. It's an option to use a list
of 3-tuples or a list of dictionaries with three keys (denomination,
plural and count).
Thanks.
--
~noufal
http://nibrahim.net.in/
More information about the Tutor
mailing list