How do i structure my Python Project?

71 views Asked by At

I have a question on correct structure for python projects. I have looked at some examples on best practices. However, I feel my case is slightly different to the examples I was looking at so I am here. This is an overview

  1. Python Project (Functional Paradigm)
  2. I need to do three things : a) 15 Different Algorithms (each approx 1 page) b) Statistics : Pre compute statistics that can be fed into algorithms later c) Reading / Writing CSVs, Cleansing Data, adding to data frames etc (which can then be uniquely called from the different algorithm code)
  3. The above needs to run in the order of c,b,a.

Two Questions : 1. Would you have any suggestions for folder structure for the project 2. How do i sequentially call c,b,a : Should i invoke them in

           if __name__ == '__main__':

or should I have a separate script governing this that is outside of the project?

This needs to be production quality which is why i have all these questions.

1

There are 1 answers

0
Stephen Rauch On
if __name__ == '__main__':

Is reasonable if your script is going to be run. I assume since you are talking about a library, that you will distributing a module to be included in other scripts. If so, then __main__ is not appropriate.

If you need to enforce a strict order, I would suggest a function/method called process, execute, etc, that takes the governing parameters (filenames, list of appropriate algorithms, etc) and then invokes these things in the appropriate sequence.