Python 3K or Python 2.9?

Aahz aahz at pythoncraft.com
Thu Sep 13 22:41:31 EDT 2007


In article <1i4bm7a.1s51u591kreqe4N%aleax at mac.com>,
Alex Martelli <aleax at mac.com> wrote:
>Chris Mellon <arkanes at gmail.com> wrote:
>> 
>> 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.

While you have a point, I do think that there is no solution that allows
the following code to work with no marker distinguishing the local bar
from the instance's bar; the only question is how you want to mark up
your code:

class C:
    def foo(self, bar):
        print bar, self.bar

x = C()
x.bar = 'abc'
x.foo()

>From that standpoint, there is a technical objection involved.  Of
course, the solution can be any of a number of different marker systems
(or even choosing to have no marker and not permit a method to access
both object attributes and locals of the same name), and Python has
chosen to force the use of a marker for all object attributes, while also
choosing to have disjoint namespaces WRT globals and locals for any one
name.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
http://www.lysator.liu.se/c/ten-commandments.html



More information about the Python-list mailing list