You need to use self.
to call another method of the same class:
class Foo:
def __init__(self):
pass
def method1(self):
print('Method 1')
def method2(self):
print('Method 2')
self.method1()
More Related Contents:
- @classmethod vs @staticmethod in Python
- Difference between @staticmethod and @classmethod
- Adding a Method to an Existing Object Instance
- TypeError: method() takes 1 positional argument but 2 were given
- Why do you need explicitly have the “self” argument in a Python method?
- What is the difference between a function, an unbound method and a bound method?
- Why does Python code use len() function instead of a length method?
- Using the class as a type hint for arguments in its methods [duplicate]
- Difference between methods and functions, in Python compared to C++
- How do I access Class member variables in Python?
- Prevent creating new attributes outside __init__
- Why is `object` an instance of `type` and `type` an instance of `object`?
- Difference between methods and attributes in python
- How do I access instance variables in Python?
- What is a “callable” in Python?
- How to access class (static) variables in Python?
- How do I access Class member variables?
- Adding a method to an existing object instance in Python
- How do I set and access attributes of a class? [duplicate]
- How do you change the value of one attribute by changing the value of another? (dependent attributes)
- In Python, when are two objects the same?
- Same name for classmethod and instancemethod
- Why does setattr fail on a bound method
- Why are python static/class method not callable?
- Which of the 4 ways to call super() in Python 3 to use?
- Print the result obtained from an external window but without opening the window (the selected checkboxes are automatically saved in the database)
- Syntax error on print with Python 3 [duplicate]
- Let JSON object accept bytes or let urlopen output strings
- builtins.TypeError: must be str, not bytes
- Is super() broken in Python-2.x? [closed]