[Python-Dev] Dotted/indexed defs ? Re: PEP 8: Discourage named lambdas?

Boris Borcic bborcic at gmail.com
Mon May 5 12:43:14 CEST 2008


Mike Klaas wrote:

> Another thing to consider is that the def() pattern is only possible 
> when the bound variable has no dots.  A common pattern for me is to 
> replace an instances method with a lambda to add monitoring hooks or 
> disable certain functionality:
> 
> inst.get_foo = lambda: FakeFoo()

Good point. That one may write eg

     for inst.bar in range(10) : do_something()

makes one wonder whether

     def inst.bar(...) : ...

or even

     def fn[k](...) : ...

should be similarly permitted. Has this ever been discussed ?

Regards, BB



More information about the Python-Dev mailing list