in my everyday job I write different models and for each model I need to create a python file like this:
class SomeModel:
def define_params(self):
return
def define_input(self):
return
def run_model(self):
return
I want to write a python script which will create a file with this format.
I tried:
import os
path = 'path_tol_folder_in_which_to_store_the_file'
if not os.path.exists(path):
os.makedirs(path)
with open(os.path.join(path, 'some_model.py'), 'w') as some_model:
some_model.writelines(
'class SomeModel:'
' def define_params(csv):'
' csv = ("PD", STRING)'
' return csv'
)
When I run this code, the file is created but in there there is only one line:
class SomeModel: def define_params(csv): csv = ("PD", STRING) return csv (imagine this is one line)
and when I do ctrl+alt+L (format code) it does not format the code the way it should be.
Is there a way to do this so that the code format in the file is correct, i.e.
class SomeModel:
def define_params(csv):
csv = ("PD", STRING)
return csv
Thanks