On Sep 25, 11:41 pm, Jayden <[email protected]> wrote:
> Dear All,
>
> In the Python Tutorial, Section 9.4, it is said that
>
> "Data attributes override method attributes with the same name."
>
> But in my testing as follows:
>
> #Begin
> class A:
> i = 10
> def i():
> print 'i'
>
> A.i
> <unbound method A.i>
> #End
>
> I think A.i should be the number 10 but it is the method. There must be
> something I misunderstand. Would you please tell me why?
What the tutorial is referring to is this, I think:
class A(object):
def i(self):
print 'i'
>>> a = A()
>>> a.i = 10
>>> a.i
10
That is, you can create a data attribute on an object even if a method
attribute of the same name exists.
--
http://mail.python.org/mailman/listinfo/python-list