What is the __init__ method in Python?

Опубликовано: 08 Октябрь 2024
на канале: Python Morsels
2,269
73

The __init_‍_ method is used to initialize a class in Python. This initializer method accepts self (the class instance) along with any arguments the class accepts and then performs initialization steps.

Read an article version of this video at https://pym.dev/what-is-init/

Find more Python screencasts at https://pym.dev/screencasts/

00:00 A pointless Point class
00:40 The initializer method
02:01 Python calls ‍__init__‍ whenever a class is called
02:48 Recap