Skip to content
Open
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
24 changes: 12 additions & 12 deletions source/docs/functions/classmethod.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ bar
Example 2
=========
>>> #This example shows usage of decorator syntax which is recommended
class Line:
def __init__(self, length):
self.length = length

@classmethod
def from_inches(cls, length_in):
length = float(length_in)*2.54
return cls(length)

l = Line.from_inches(3)
print l.length #returns 7.62
>>> class Line:
... def __init__(self, length):
... self.length = length
...
... @classmethod
... def from_inches(cls, length_in):
... length = float(length_in)*2.54
... return cls(length)
...
>>> l = Line.from_inches(3)
>>> print l.length #returns 7.62

See Also
========
#TODO
#TODO