generator expression works in shell, NameError in script

Jason Tackaberry tack at urandom.ca
Thu Jun 18 00:41:44 CEST 2009


On Wed, 2009-06-17 at 15:38 -0700, Chris Rebert wrote:
> See what Emile said, but here's a nicer way to code it, IMHO:
> 
> titles = ['Dr', 'Miss', 'Mr', 'Mrs', 'Ms']
> title_choices = zip(range(len(titles)+1), ['']+titles)
> 
> zip() to the rescue!

How about:

   enumerate([''] + titles)




More information about the Python-list mailing list