mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 07:12:31 +03:00
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.
This commit is contained in:
parent
75abbf209e
commit
eba9d9ffe5
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user