Norman Khine wrote:
Hello,
I have this code, is there a better way to get the desired output.
http://paste.lisp.org/display/72966
I'd add the variable information e g. ('fr', 'ascii', '%.2f', '%s %s'])
to the individual dictionaries. Then all the relevant data is in one
place. Then you need no if statement.
I also assume that only one dictionary will be selected. Then you don't
need the for loop.
x = [d for d in currencies if d['is_selected'] == True][0]
This could be a great application for the recently discussed
namedtuples, to be used in lieu of the dictionaries.
--
Bob Gailer
Chapel Hill NC
919-636-4239
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor