[Tutor] Another try at Python's selfishness

Ed Singleton singletoned at gmail.com
Fri Feb 3 13:44:45 CET 2006


On 3 Feb 2006 03:59:10 -0800, n.estner at gmx.de <n.estner at gmx.de> wrote:
> > I still see "newbie-friendliness" as a
> > MAJOR plus for Python -- it increases the chance that users
> > of your software will become contributors.
>
> Yes, I 100% agree to that point!
> But the point is, the current situation is not newbie-friendly (I can
> tell, I am a newbie): I declare a method with 3 parameters but when I
> call it I only pass 2 parameters. That's confusing. If I declare a
> member variable, I write: "self.x  = ValueForX", why can't I be equally
> explicit for declaring member functions?

I have to say that as a newbie, it took me quite a while to get my
head around that extra parameter (self).

It took me ages to work out that:

class A:
   def __init__(self, foo):
       self.foo = foo

a = A("hello")

is actually a shortcut for:

a = A(a, "Hello")

or even:

a = new A(a, "Hello")

I think insisting on:


a = A(a, "Hello")

would be very good for readability, understandability and newbie-friendliness.

Ed


More information about the Tutor mailing list