flâneur — a map of the web's best reading

Python __init__

pythontutorial.net · 410 words · saved by 1 readers

Summary: in this tutorial, you’ll learn how to use the Python __init__() method to initialize object’s attributes. When you create a new object of a class, Python automatically calls the __init__() method to initialize the object’s attributes. Unlike regular methods, the __init__() method has two underscores (__) on each side. Therefore, the __init__() is often called dunder init. The name comes abbreviation of the double underscores init. The double underscores at both sides of the __init__() method indicate that Python will use the method internally. In other words, you should not explicitly call this method. Since Python will automatically call the __init__() method immediately after creating a new object, you can use the __init__() method to initialize the object’s attributes. The following defines the Person class with the __init__() method: When you create an instance of the Person class, Python performs two things: Note that the __init__ method doesn’t create the object but only

Summary : in this tutorial, you’ll learn how to use the Python __init__() method to initialize object’s attributes. Introduction to the Python __init__() method # When you create a new object of a class , Python automatically calls the __init__() method to initialize the object’s attributes . Unlike regular methods , the __init__() method has two underscores (__) on each side. Therefore, the __init__() is often called dunder init. The name comes abbreviation of the double underscores init. The double underscores at both sides of the __init__() method indicate that Python will

Explore this link on the map →

related reading