UrbanPro

Learn Python Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What does "self" mean in a Python class? Why do we need it?

Asked by Last Modified  

2 Answers

Learn Python

Follow 2
Answer

Please enter your answer

Web developer with more than 4 years of experience.

Think about self as a function that i created for myself.(by myself i mean the object) When we use self we are refering to any future instance that we may create and store data. on self we can create any functions and all other things required for that object. self allows us to also access functions...
read more

Think about self as a function that i created for myself.(by myself i mean the object) When we use self we are refering to any future instance that we may create and store data. on self we can create any functions and all other things required for that object. self allows us to also access functions of the current class inside the same class.

read less
Comments

IIT Roorkee Grad and an IT Professional with 10 Years of Experience

There are methods and functions in python. Methods specifically refer to functions that are defined within a class or are bound to a particular class. functions on the other hand are not bound to any class and are available globally. So when I am defining a method in a class which needs to call another...
read more

There are methods and functions in python. Methods specifically refer to functions that are defined within a class or are bound to a particular class. functions on the other hand are not bound to any class and are available globally. So when I am defining a method in a class which needs to call another method inside the same class, how will we do it? If we simply use the method name and pass the parameters it will not work as it will try to find functions defined globally. But if you do self.method_name() then it will work. So this is one scenario that shows the usage of self in python. Using self we can call methods defined inside the current class. Think of the self as a pointer to a class object. So when you do self.method_name() the method_name defined inside the class will execute

read less
Comments

Related Questions

I completed my graduation in 2017, now working as an HR Executive in a Consultancy. I want to move to IT Sector. Which course is best for me to learn and get success in life? Please Suggest me
Dear Kumar, My suggestion is to - become good in one programming language - preferably Java and one O/S preferably Linux. Be aware of Open Source systems. Try to identify the opportunities in your existing...
Kumar
Where can I get Python online training?
You can get many institutes in google which are providing online training.
Taranum
How do I learn Python?
Start with online tutorials, books, and practice coding. Join communities and work on projects to improve.
Kirti
0 0
6

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Writing Simple programs in Python(cont.)
To start writing simple programs in Python, we have to know firstly the SW development process and then we also have to know a bit about the language in which we wish to code,in this case,python, to get...

Python : functional programming characteristics
Functions are first class (objects). That is, everything you can do with "data" can be done with functions themselves (such as passing a function to another function). Recursion is used as a primary...


Two lists using Loops - Python Program 1
To generate a list of all possible combinations of two lists using loops, you can use nested loops to iterate through both lists and create a new list that contains all the combinations. list1 = list2...

Write your first Python program in 10 minutes
1. Download python from python official site search "python download" in google 2. Install in your machine 3. verify using : "python --version" command 4. Write first program using notepad create...

Recommended Articles

Python is one of the most popular programming languages in the world. It is general-purpose, object oriented, high-level programming language used in a number of programming fields. Python is a great programming language to learn as it will introduce you to the world of programming. If you are from the technical background...

Read full article >

Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...

Read full article >

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Almost all of us, inside the pocket, bag or on the table have a mobile phone, out of which 90% of us have a smartphone. The technology is advancing rapidly. When it comes to mobile phones, people today want much more than just making phone calls and playing games on the go. People now want instant access to all their business...

Read full article >

Looking for Python Training classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Python Training Classes?

The best tutors for Python Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Python Training with the Best Tutors

The best Tutors for Python Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more