generator expression works in shell, NameError in script
greg at cosc.canterbury.ac.nz
Fri Jun 19 06:20:55 CEST 2009
> class SignupForm(Form):
> titles = ['Dr', 'Miss', 'Mr', 'Mrs', 'Ms',]
> title_choices = [(0, '')] + list((titles.index(t)+1, t) for t in
> Does the generator expression have its own little namespace or so ?
Yes. The generator expression is a function, with its
own local namespace. Since the class scope is not visible
from inside functions declared within it, the behaviour
you're seeing results.
More information about the Python-list