is Python fully object oriented ?

David C. Ullrich ullrich at math.okstate.edu
Fri Jan 12 13:30:15 EST 2001


In article <mailman.979292174.19166.python-list at python.org>,
  =?iso-8859-1?Q?Max_M=F8ller_Rasmussen?= <maxm at normik.dk> wrote:
> From: Simon Brunning [mailto:SBrunning at trisystems.co.uk]
>
> >> I don't know if this helps, but it's perfectly legal to use a name
other
> >> than "self" in Python, e.g.,
> >>
> >> class SpamChunk:
> >>   def __init__(s):
> >>     s.color = 'green'
> >>
> >It's also legal never to wash, but you won't make many friends that
way,
> >either.
>
> It's the only thing about Python that bothers me endlessly, having to
> explicitly pass "self".
>
> In javascript ie. "this" is implicit and that is so much simpler.
>
> I know it breaks the rule of "Explicit is better than implicit" but
this
> ought to to be an exception as it is so commonly used. (And I so
commonly
> make the mistake of forgetting it ;-) )
>
> Is there a REALLY good reason that it has to be explicitly declared ?

Makes a lot of things easier. Like it makes it easy to invoke
a method of a class on something other than an instance of that
class, which is actually a perfectly standard idiom around here:

class A:
  def __init__(self):
    pass

class B(A):
  def __init__(self):
    A.__init__(self)

A person could invent syntax to do exactly that one thing
with an implicit self, maybe with an "inherited" keyword
as in the one language I know with an implicit self (Object
Pascal). How would a person do

class C(A, B):
  def __init__(self):
    A.__init__(self)
    B.__init__(self)

with an implicit self?

DU

> Regards Max M
>
>

--
Oh, dejanews lets you add a sig - that's useful...


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list