Problem of Readability of Python
Brian Elmegaard
brian at rkspeed-rugby.dk
Sun Oct 7 16:06:59 EDT 2007
Bruno Desthuilliers <bruno.42.desthuilliers at wtf.websiteburo.oops.com>
writes:
> Use dicts, not lists or tuples:
>
> a = dict(name='yadda', val=42)
> print a['name']
> print a['val']
I guess you will then need a list or tuple to store the dicts?
I might have made it with a list of class instances:
class a:
def __init__(self,name,val):
self.name=name
self.val=val
l=list()
l.append(a('yadda',42))
print l[0].name
print l[0].val
Is the dict preferable to a list or tuple of class instances?
--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk
More information about the Python-list
mailing list