Can I replace this for loop with a join?

Ben Finney ben+python at benfinney.id.au
Mon Jun 22 00:09:45 CEST 2009


Paul Watson <paul.hermeneutic at 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.

-- 
 \       “Crime is contagious… if the government becomes a lawbreaker, |
  `\          it breeds contempt for the law.” —Justice Louis Brandeis |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list