import class python code example
Example 1: how to import your own function python
from fileName import function1()
fileName.function1()
from fileName import function1(), function2()
fileName.function1()
fileName.function2()
from fileName import *
function1()
function2()
function3()
Example 2: import class from another file python
from <file that has the class in> import <the class name you want to import>
from <file that has the class in> import *
Example 3: module import class python
class myClass:
def __init__(self,val):
self.val=val
def getVal(self):
return self.val
Example 4: import class from another file python
from folder.file import Klasa
from folder import file
k = file.Klasa()
import folder.file as myModule
k = myModule.Klasa()