What is the difference between new and init in Python?

__ new__ accepts a type as the first argument, and (usually) returns a new instance of that type. Thus it is suitable for use with both mutable and immutable types. __init__ accepts an instance as the first argument and modifies the attributes of that instance.

Sizin İçin Seçtik  Can I use both context and Redux?

Leave a Reply

Your email address will not be published. Required fields are marked *