Learn Before
Concept
Methods vs. Functions
A method is a function that is explicitly tied to a class. Unlike regular functions, methods require an object instance of the class it is tied to in order to be called.
class MyClass: def __init__(self, n, a): selt.name = n self.age = a def myName(self): print(self.name) myName() # This method cannot be called on its own Jim = MyClass("Jim", 25) Jim.myName() # This call works
0
1
Updated 2021-02-09
Tags
Python Programming Language
Data Science
Related
Defining Classes in Python
Class Variable vs Instance Variable
Class Inheritance
"Self" Keyword in Python Class
init() method in Python
Methods vs. Functions
Encapsulation in Python
Class Composition
Math Constants
Math Constants
Useful Math Constants in Python
The add_to_class Utility Function
The HyperParameters Utility Class
The ProgressBoard Utility Class
Base Module Class in Deep Learning Implementation