From f8694d1ab2df38c0359179ed1a4479bf412ce8b8 Mon Sep 17 00:00:00 2001 From: Stefan Marinov Date: Fri, 14 Mar 2014 15:58:39 +0100 Subject: [PATCH] [03-oop] Multiple missing colons after function/method definitions --- lectures/03-oop.slim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lectures/03-oop.slim b/lectures/03-oop.slim index 9c6305e..42df310 100644 --- a/lectures/03-oop.slim +++ b/lectures/03-oop.slim @@ -39,7 +39,7 @@ class Vector: def __init__(self, x, y, z): ... - def length(self) + def length(self): return (self.x * self.x + self.y * self.y + self.z * self.z) ** 0.5 spam = Vector(1.0, 2.0, 3.0) @@ -115,7 +115,7 @@ self.y /= length self.z /= length - def normalized(self) + def normalized(self): return Vector(self.x / self.length(), self.y / self.length(), self.z / self.length()) @@ -134,7 +134,7 @@ def __init__(self, x, y, z): self._coords = (x, y, z) - def __eq__(self, other) + def __eq__(self, other): return self._coords == other._coords li.action По подразбиране, __eq__ е имплементирана с is @@ -169,7 +169,7 @@ example: class Stamp: def __init__(self, name): self.name = name - def __call__(self, something) + def __call__(self, something): print("{0} was stamped by {1}".format(something, self.name)) >>> stamp = Stamp("The government")