list vs. dict
dsavitsk
dsavitsk at e-coli.net
Wed Feb 27 14:17:11 EST 2002
"Max M" <maxm at mxm.dk> wrote in message news:3C7CFAF8.1080108 at mxm.dk...
> Beda Kosata wrote:
>
<snip>
> btw: if you really want to store it in a list you can get dict-like
> behaviour with list speed like this:
>
> keys = (
> NAME, AGE, SEX
> ) = range(3)
> def pseudoDict():
> return [None]*len(keys)
>
> items = []
>
> person = pseudoDict()
> person[NAME] = 'Max M'
> person[AGE] = 36
> person[SEX] = 'Male'
> items.append(person)
>
<snip>
> regards Max M
>
is this a python idiom that people often use? cause i've not seen it before,
but it is really clever.
More information about the Python-list
mailing list