Answers for "__init__ python full form"

3

self and init in python

class Computer:
    def __init__(self):
        self.name= ("Pankaj")
        self.age= 28
c1=Computer()
c2=Computer()
c1.name= "Garg"
print(c1.name)
print(c2.name)
Posted by: Guest on December-26-2020
1

__init__.py file in python

# __init__.py
# you can comment here about your package.
# you can also add external libraries to your package.
# for example:
import numpy
import pandas

# you can also add your package information in this file.
__version__ = '2.1.1'
__author__ = 'Depressed Dingo'

# __all__ make others able to access to this datas by importing our package.
__all__ = ['numpy', 'pandas', '__version__', '__author__']


# -----------------------------------------
# main.py
# example of using this.

from test_package import *
# or
from test_package import numpy

print(__auther__) # --> Depressed Dingo
Posted by: Guest on September-27-2021

Python Answers by Framework

Browse Popular Code Answers by Language