Skip to content

[03-oop] Multiple missing colons after function/method definitions #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lectures/03-oop.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())

Expand All @@ -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

Expand Down Expand Up @@ -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")
Expand Down