Ben Finney wrote: > Paul Watson <paul.hermeneu...@gmail.com> writes: >> On Mon, 2009-04-13 at 17:03 +0200, WP wrote: >> > dict = {1:'astring', 2:'anotherstring'} >> > for key in dict.keys(): >> > print 'Press %i for %s' % (key, dict[key]) >> >> In addition to the comments already made, this code will be quite >> broken if there is ever a need to localize your package in another >> language. > > How is this code especially broken? AFAICT, it merely needs the strings > marked for translation, which is the best i18n situation any regular > program can hope for anyway. >
The problem is that some language might require you to write "For X press Y", which is impossible to achieve here. I think percent-formatting supports using keys, like "Press %{key} for %{action}" % {'key': key, 'action':dict[key]} However, I would also like to hear what Paul really meant and also the alternatives he proposes. Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list