What does a class’s init() method do?

Advertisement

  • The __init__ method makes classes aware of each other if more than one class is defined in a single code file.
  • The__init__ method is included to preserve backwards compatibility from Python 3 to Python 2, but no longer needs to be used in Python 3.
  • The __init__ method is a constructor method that is called automatically whenever a new object is created from a class. It sets the initial state of a new object.
  • The __init__ method initializes any imports you may have included at the top of your file.
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Comment


Share via
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Send this to a friend