__new__ VS __init__ in Python

preview_player
Показать описание
#__new__ #__init__ #class #python

In this video, we'll discuss about __new__ and __init__ methods. The __new__ and __init__ methods in Python. Learn how __new__ is responsible for creating instances of a class while __init__ initializes newly created objects.

More 2 Minutes Python Tutorial:

@2MinutesPy
Рекомендации по теме
Комментарии
Автор

You made my day! Instead of watching too long 20-min videos, I just have a well exampling 2-min video with all I need.

szymonpiechutowski
Автор

Watched a 2:30 minute video that was better than a 20 min tutorial, thanks bro !

ryanalvim
Автор

But by default if you just use __init__, where does __new__ get called from? The answer is object via inheritance? or type in a Meta.

derekreed
Автор

about o use __new__ for data validation (using pydantic because well duh) and thanks again

compositeboson
Автор

I guess still a very long journey on Python Learning 😅

spidey