[Python-ideas] Assignments in list/generator expressions

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Apr 12 01:32:52 CEST 2011


Nick Coghlan wrote:

> I also thought of a somewhat decent use case for the feature, too:
> "builder" code in module and class namespaces,

It would also give you a really nice way to define properties:

   foo = property(get, set) given:

     def get(self):
       ...

     def set(self, x):
       ...

and to pass thunks to functions:

   do_something(blarg, body) given:
     def body(stuff):
       ...

-- 
Greg



More information about the Python-ideas mailing list