Python 3K or Python 2.9?

Alex Martelli aleax at mac.com
Wed Sep 12 12:43:57 EDT 2007


Chris Mellon <arkanes at gmail.com> wrote:
   ...
> > Actually you could do the "magic first-parameter insertion" just when
> > returning a bound or unbound method object in the function's __get__
> > special method, and that would cover all of the technical issues you
   ...
> This would mean that mixing functions and methods would have to be
> done like you do it in C++, with lots of careful knowledge and
> inspection of what you're working with.

Not particularly -- it would not require anything special that's not
required today.

> What would happen to stuff
> like inspect.getargspec?

It would return the signature of the function, if asked to analyze a
function, and the signature of the method, if asked to analyze a method.
Not exactly rocket science, as it happens.


> Besides, if self isn't in the argument spec, you know that the very
> next thing people will complain about is that it's not implicitly used
> for locals,

Whether 'self' needs to be explicit as a function's first argument, and
whether it needs to be explicit (as a "self." ``prefix'') to access
instance variables (which is what I guess you mean here by "locals",
since reading it as written makes zero sense), are of course separate
issues.

> and I'll punch a kitten before I accept having to read
> Python code guessing if something is a global, a local, or part of
> self like I do in C++.

Exactly: the technical objections that are being raised are bogus, and
the REAL objections from the Python community boil down to: we like it
better the way it is now.  Bringing technical objections that are easily
debunked doesn't _strengthen_ our real case: in fact, it _weakens_ it.
So, I'd rather see discussants focus on how things SHOULD be, rather
than argue they must stay that way because of technical difficulties
that do not really apply.

The real advantage of making 'self' explicit is that it IS explicit, and
we like it that way, just as much as its critics detest it.  Just like,
say, significant indentation, it's a deep part of Python's culture,
tradition, preferences, and mindset, and neither is going to go away (I
suspect, in fact, that, even if Guido somehow suddenly changed his mind,
these are issues on which even he couldn't impose a change at this point
without causing a fork in the community).  Making up weak technical
objections (ones that ignore the possibilities of __get__ or focus on
something so "absolutely central" to everyday programming practice as
inspect.getargspec [!!!], for example;-) is just not the right way to
communicate this state of affairs.


Alex



More information about the Python-list mailing list