Created
March 15, 2023 15:51
-
-
Save justinchuby/dbe99ce7ddbebb92d5d453f34afd3fa5 to your computer and use it in GitHub Desktop.
Python passes in self to its methods as the first argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [3]: def foo(*a): print(a) | |
In [4]: class Test: | |
...: func = foo | |
...: def bar(self): | |
...: self.func(42) | |
...: | |
In [5]: Test().bar() | |
(<__main__.Test object at 0x106751ab0>, 42) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like it. That's good learning.