Missing the functional mind set

Rainer Deyke root at rainerdeyke.com
Sat Mar 3 19:41:29 EST 2001


"Daniel Klein" <danielk at aracnet.com> wrote in message
news:t6f2at870pk82q96bnd5a2od4n8ns5kf83 at 4ax.com...
> On Sat, 03 Mar 2001 18:22:18 GMT, "Rainer Deyke" <root at rainerdeyke.com>
wrote:
>
> >But if you are indexing with integers from 0 to n, why are you using a
> >dictionary in the first place?
>
> I'm not sure I understand your question. I need the dictionary to
associate a
> numbered key with a value. Rather than force the user to enter elements
'in
> order' I am letting them specify what the order is on-the-fly, ie enter
element
> 3 first, then 1, then 2, then 0. The method will the place the values in
the
> proper order for further processing.

Assuming the elements are numbered from '0' to 'n - 1' *and* 'n' is know
ahead of time, you could just create the list as '[None] * n' and use it
instead of the dictionary.  If 'n' is not known ahead of time, this may be
more trouble than it's worth.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list