In python, which of the following files is mandatory to treat a folder as a package?

When we write a python code and closes it, it disappears. So we have to save it in a file to use it again.
Similarly, when we use __init__ .py in a name of folder we have to treat it as package and use it as package.
__init__ is used to initialize object in a class. It is a reserved method in python classes.
It indicates what data must be supplied when an instance of class is created and how that data is stored internally.
It is a constructor in python.
syntax:-
class name_of_class(): def __init__(self,arg1, argu2): self.arg1=arg1 self.arg2=arg2
This is all about __init__ in python.
When we save a folder __init__.py name we have to use that folder as package.
Subscribe
Login
Please login to comment
0 Discussion