On Dec 6, 12:47 am, "Patrick Mullen" <[EMAIL PROTECTED]> wrote:
> Could I do something like this:
>
> def a.add(b): return a+b
>
> Outside of a class?  Of course then that makes you think you could do
> 5.add(6) or something craaaazy like that.  (I mean, you can do
> (5).__add__(6) but that's something else entirely)


I'd be inclined to think that this defines an instancemethod on an
existing object a.  In other word, I'd read the following two lines as
more or less equivalent.

def a.add(b): return a+b

a.add = lambda b: a+b


Just as the following are equivalent:

def foo(): return bar

foo = lambda: bar


I had been -0 on this, but now I think I'm -1.


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

Reply via email to