Search for mapping solution

John J. Lee jjl at pobox.com
Sun Jul 6 15:55:18 EDT 2003


Markus Joschko <jocsch at phreaker.net> writes:
[...]
> I have a List:
> 
> nName - Number - Costs
[...]
> > lines = [['fred','333','0,10'],['sam','444','1'],['fred','333','0,50']]
[...]

Note that tuples were designed for that sort of 'mini-object' use (and
were not intended primarily as immutable lists).

lines = [('fred','333','0,10'), ('sam','444','1'), ('fred','333','0,50')]


though of course it's no disaster if you end up with a list of
3-element lists instead of 3-tuples, if it's convenient to build the
list with zip or whatever.


John




More information about the Python-list mailing list