the annoying, verbose self
Duncan Booth
duncan.booth at invalid.invalid
Tue Nov 27 07:03:41 EST 2007
Iain King <iainking at gmail.com> wrote:
> FTR, I won't be using this :) I do like this syntax though:
>
> class Vector:
> def __init__(self, x, y, z):
> self.x = x
> self.y = y
> self.z = z
> def abs(self):
> using self:
> return math.sqrt(.x*.x + .y*.y + .z*.z)
It is a bit verbose though. This variant is shorter on my system[*]:
class Vector:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def abs(self):
return math.sqrt(self.x*self.x + self.y*self.y + self.z*self.z)
[*] Windows, they are the same length on Linux.
:)
More information about the Python-list
mailing list