the annoying, verbose self
BJörn Lindqvist
bjourne at gmail.com
Mon Nov 26 08:22:08 EST 2007
On Nov 24, 2007 11:55 AM, jakub silar <jakub.silar at volny.cz> wrote:
> Below is my coding standard - I'm lazy, even lazy to persuade
> comutinties into strange (imho) language syntax extensions.
>
>
> class Vector:
> def __init__(s, x, y, z):
> s.x = x
> s.y = y
> s.z = z
> def abs(s):
> return math.sqrt(s.x * s.x + s.y * s.y + s.z * s.z)
>
> Admit that changing habits may be more difficult then to change a
> language syntax.
Yes, indeed. A self-reference prefix like "s", "T", "_" or even "my"
would be enough characters shorter than "self." But self *is* the
convention and just because the language allows you to break it
doesn't mean that it is not horribly wrong to do so. :)
--
mvh Björn
More information about the Python-list
mailing list