how to import __init__.py code example

Example 1: __init__ python

class Person:
  def __init__(self, name, age):
    self.name = name
    self.age = age

p1 = Person("John", 36) // Object definition

print(p1.name)
print(p1.age)

Example 2: what is __init__ in python

# If you are familiar with C++ or Java think of the __init__ method as a constructor.
# It is the method that is being called when the class is called.In the following
# example we will see how we can call the __init__ method

my_variable = MyClass()

Example 3: import __init__.py

# use this for python script(s) in same folder where __init__.py is in
# it'll save typing up common imports for multiple python scripts
from . import *

# if want to be specific
from . import hello_world