I have only been programming in python for a year now so am still learning a lot.
Not sure if my answer is 100% correct so if I get anything wrong someone will need to correct me.
For me import feels like a cut and paste from the file you have imported from. If you have a file called Logger.py and you use
import Logger then it cuts and pastes the contents of Logger.py. If you use
from Logger import my_function then it will cut and paste the function called my_function from the file Logger.py. If you type
from Logger import my_class then it will cut and paste the class(object) called my_class from the file Logger.py.
Once you have imported the function or class then you can pass arguments to it e.g my_function(arguments)
Once you import a class(object) then you can create and instance of it and pass arguments to it e.g my_pointer = my_class(init_arguments)
Hopefully I am at least part right with my answer
So for your Logger code you can turn it into a class and use it something like this
Code: Select all
from Logger import logger_class
my_logger = logger_class(init_argumanets)
#if you want to interact with a fuction in the logger_class you can do it like this
#my_logger.my_fuction(arguments)