Licheng Fang wrote: > struct nameval { > char * name; > int val; > } a; > > a.name = ... > a.val = ... > > becomes cryptic > > a[0] = ... > a[1] = ...
?! (1) a = {} a["name"] = ... a["val"] = ... (2) NAME = 0 VAL = 1 a=[] a[NAME] = ... a[VAL] = ... > Python Tutorial says an empty class can be used to do this. But if > namespaces are implemented as dicts, wouldn't it incur much > overhead if one defines empty classes as such for some very > frequently used data structures of the program? Measure first, optimize later. How many million of instances and/or accesses per second do you have? Regards, Björn -- BOFH excuse #20: divide-by-zero error -- http://mail.python.org/mailman/listinfo/python-list