init and self in python

0 votes

When we define a method such as :

def method(self, blah):
    def __init__(?):
What is the use of self and __init__ ? are they mandatory? 
Sep 17, 2018 in Python by ana1504.k
• 7,910 points
898 views

1 answer to this question.

0 votes

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. 

answered Sep 18, 2018 by SayantiniDeb
• 200 points

Related Questions In Python

0 votes
0 answers

What do __init__ and self do in Python? [duplicate]

During my Python lectures, I've come across a ...READ MORE

Aug 31, 2023 in Python by Edureka
• 220 points
219 views
0 votes
1 answer

What is the key difference between self in ruby and self in python?

Ruby and Python are actually very different languages (although ...READ MORE

answered Jul 30, 2019 in Python by Mohammad
• 3,230 points
963 views
0 votes
1 answer

Can you explain what is the use _init_ and self in python?

Hi, The basic difference between these two are _init_ ...READ MORE

answered Aug 14, 2019 in Python by anonymous
1,435 views
0 votes
1 answer

What do "init" and "self" do in python ?

In Python, `init` and `self` are related ...READ MORE

answered Oct 5, 2023 in Python by anonymous
• 3,360 points
707 views
0 votes
1 answer

How can I find out the index of an element from row and column in Python?

You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,720 points
2,222 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,348 views
0 votes
1 answer
0 votes
1 answer

How to write "not equal" in python?

The keywords is and is not are ...READ MORE

answered Sep 18, 2018 in Python by SayantiniDeb
• 200 points
2,360 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP