summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrew Lee <leeandrew116@gmail.com>2017-03-01 01:15:36 +0900
committerven <vendethiel@hotmail.fr>2017-02-28 17:15:36 +0100
commiteba9d9ffe54de39ebceb07769d1151ac3d0f5e14 (patch)
tree92191d02640eb1a3148bb52f53a26c8110479708
parent75abbf209e1e7c0c64f0cf5be862f93c82dfcb7b (diff)
Updated mistake in Python3/en tutorial (#2678)
A fix on static method section (around line 728). Specifically, i.grunt() should raise an error since grunt() is a static method and 'i' is an instance of the class.
-rw-r--r--python3.html.markdown7
1 files changed, 5 insertions, 2 deletions
diff --git a/python3.html.markdown b/python3.html.markdown
index b701d558..6a2a7ccd 100644
--- a/python3.html.markdown
+++ b/python3.html.markdown
@@ -724,8 +724,11 @@ if __name__ == '__main__':
# Call the static method
print(Human.grunt()) # => "*grunt*"
- print(i.grunt()) # => "*grunt*"
-
+
+ # Cannot call static method with instance of object
+ # because i.grunt() will automatically put "self" (the object i) as an argument
+ print(i.grunt()) # => TypeError: grunt() takes 0 positional arguments but 1 was given
+
# Update the property for this instance
i.age = 42
# Get the property