PEP 318
Stephen Horne
steve at ninereeds.fsnet.co.uk
Mon Mar 22 05:45:40 EST 2004
On Sun, 21 Mar 2004 14:45:39 -0500, Nicolas Fleury
<nid_oizo at yahoo.com_removethe_> wrote:
>- Give a warning for all methods with first parameter not named "self"
>in next versions of Python.
>- In a future major version of Python, 3 or 4, self becomes a keyword
>and a first parameter named otherwise implies a class method (I
>understand it could mean a lot of changes in code not using self).
The main problem I have with that is that some people find typing
'self.' over and over in member functions pretty annoying. I have
quite recently voiced the opinion that because 'self' is just a
convention, that it can reasonably be abbreviated to become something
like 's' or 'm', so that 'm.' in Python code plays much the same role
as 'm_' in common use as a prefix for member variable names in C++.
As I said then, I'm not that bothered about 'self.' - keeping to the
well-known convention and the principle of least surprise is to me
well worth pressing a few more keys. But I may have to deal with a few
grumpy people if that suggestion turns out bad :-(
If a more radical change is needed, then I would say we need an
alternative to the 'def' keyword. It could be justified as 'def just
defines normal functions - we can define them as class members and we
have a convenient system for using them as if they were methods but
that doesn't mean they really are methods'. 'True' methods would then
be defined using a 'method' keyword, and within a method 'self' might
be a pseudo-keyword.
In Python 3000, 'def' for member functions might then be deprecated.
Very unlikely, though.
--
Steve Horne
steve at ninereeds dot fsnet dot co dot uk
More information about the Python-list
mailing list