If I have function like this
def get_time_format(value, time): for item in value: time.append(datetime.strptime(str(item),'%H').strftime('%I%P').lstrip('0').upper()) return time
For example, above function I am using across different modules, Instead of code repeation, can I put that in separate file and call them in the module whichever requires them.
Second part is related to the first one, so if I have few lines of code which is common. Can I create a file which is having all the common code lines?
hierarchy:- hello.py hello.py/ds/a.py hello.py/ds/b.py hello.py/ds/c.py hello.py/ds/d.py
Above
hello.py
is my main file anda,b,c and d
are modules.
Can some tell me where I can to create a file to share common codes within modules as asked in 1 and 2. I am new to python and using the modules for the first time.