mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-25 15:51:15 +02: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:
@@ -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
|
||||
|
Reference in New Issue
Block a user