Connecting Tech Pros Worldwide Forums | Help | Site Map

Re: Wouldn't it be nice if this worked?

Jean-Paul Calderone
Guest
 
Posts: n/a
#1: Aug 10 '08
On Mon, 11 Aug 2008 00:47:14 +0530, "Suresh V." <suresh_vv@yahoo.comwrote:
Quote:
>class A:
def add(self, x, y):
return x+y
>
>class B:
pass
>
>B.add = A.add
>
>print B().add(1, 2) <----- gives TypeError: unbound method add() must
be called with A instance as first argument
>
Why?

Closed Thread