Alexey Borzenkov wrote:
> [EMAIL PROTECTED] wrote:
> > but maybe it reduces code readabilty a bit for people
> > that have just started to program:
> >
> > mul2 = def(a, b):
> >     return a * b
> >
> > Instead of:
> >
> > def mul2(a, b):
> >     return a * b
>
> For such simple cases, yes. What about:
>
>   button.click += def(obj):
>     # do stuff
>
> You obviously can't:
>
>   def button.click(obj):
>     # do stuff
>
> :-) And if you make intermediate function and then assign it somewhere,
> it "pollutes namespace": it's still left there, unneeded.

If you're really uptight about it you can
def temp_function(...):
  ....
button.click = temp_function
del(temp_function)

But for something like the example I'd probably just use a local name
wherever the definition is needed; there's no namespace pollution in
any meaningful sense then.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to