Explicit Frustration of the Self
Sean Ross
frobozz_electric at hotmail.com
Sat Jan 4 21:51:43 EST 2003
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()'"
Now, I did say "passing self as an argument to its instance methods"
I did not say, or at least I did not intend to say, "pass self as an
argument to methods __when calling them__". In particular, it's the "when
calling them" part that I did not mean to say.
That aside, I realize I was unclear, and I apologize for any confusion.
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.
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
However, after having seen the nested class example used earlier, my
proposal(above) seemed a bit less reasonable.
And that's about it.
OK, then.
Sorry for the confusion,
Sean
"Grant Edwards" <grante at visi.com> wrote in message
news:slrnb1ev1b.bbm.grante at localhost.localdomain...
> In article <tGER9.8038$rr1.1290343 at news20.bellglobal.com>, Sean Ross
wrote:
>
> > When I first began learning python(and I still am learning), I found the
> > practice of passing self as an argument to its instance methods hackish.
I
> > didn't mind the explicit use of self(and I still don't - in fact I
prefer
> > it) but I didn't understand why passing it to its own methods was
necessary.
>
> I'm confused. I dont pass self as an argument to methods when calling
them,
> and I don't remember seeing it done in other people's code. Can you
provide
> an example of what you're talking about?
>
> --
> Grant Edwards grante Yow! I want a WESSON
> at OIL lease!!
> visi.com
More information about the Python-list
mailing list