Dictionary type access to list of instances

Duncan Booth duncan at NOSPAMrcp.co.uk
Mon Feb 25 14:20:32 CET 2002


"Grant Beasley" <gbeasley at tsa.ac.za> wrote in
news:a5dcgh$b22$1 at ctb-nnrp1.saix.net: 

> If I have a list of instances, each with a property which I want to
> use as a key to access the list in dictionary-like manner, what would
> be the best way of doing this?

Is there any reason why you can't just store your instances in a dictionary 
using the property as the key?

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list