Explicit Frustration of the Self

Grant Edwards grante at visi.com
Sat Jan 4 23:19:12 EST 2003


In article <15NR9.8673$8M3.1457830 at news20.bellglobal.com>, Sean Ross wrote:
> Perhaps "passing" was the wrong term...
> Let's see if I can clarify what I was trying to say before:
> 
> class Foo:
>     def bar(self, arg):   # method signature
>         self.data = arg
> 
> inst = Foo()
> inst.bar(None)  # method useage
> 
> When I said "passing" before, what I meant was "including 'self' as a
> parameter in the argument list for the method signature of 'bar()'"

Ah.  I see. I've always thought that rather natural, but I've never used C++
but learned OO with Smalltalk and Modula-3.

> So, anyway, all I was getting at before was that I found the disparate
> appearance of the method signature and the method useage to be ...odd.

There's something that seems initially odd about all languages I've learned.
In a "good" language, the "oddness" goes away quickly.  In a "bad" language
it seems odd forever.

Python's indention seemed extremely odd when I heard about it.  After about
15 minutes, it didn't seem odd at all.  :)

> It _seemed_ reasonable to me that their appearance should should be similar,
> i.e.,
> 
> def self.bar(arg): ... # method signature
> 
> inst.bar(None)  # method useage

I see what you mean.

Bar can be used as an unbound method, in which case its declaration mathes
its usage:

  inst = Foo()
  method = Foo.bar
  
  method(inst,None)

That's not the usual case you see used, though.

-- 
Grant Edwards                   grante             Yow!  ... I want FORTY-TWO
                                  at               TRYNEL FLOATATION SYSTEMS
                               visi.com            installed withinSIX AND A
                                                   HALF HOURS!!!




More information about the Python-list mailing list