20732/init-and-self-in-python
When we define a method such as :
def method(self, blah): def __init__(?):
What is the use of self and __init__ ? are they mandatory?
The self variable represents an instance of the object itself. while most object oriented languages pass this as a hidden parameter, it is declared explicitly in python.
The __init__ method is basically a constructor in Python. it creates an object and passes as the first parameter to the __init__ method.
During my Python lectures, I've come across a ...READ MORE
Ruby and Python are actually very different languages (although ...READ MORE
Hi, The basic difference between these two are _init_ ...READ MORE
In Python, `init` and `self` are related ...READ MORE
You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE
suppose you have a string with a ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
The keywords is and is not are ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.