Structure a program in Python

0

So, I'm creating a "road map" of creating projects in Python to consolidate the way I and my co-workers write our codes.

I developed a structure of how each project should be organized, and how we should write our variables.

That kind of leaves me with 2 questions:

How to organize my project, and how to name my variables ...

I searched online for the 2, so much so that my project structure organization was created based on that site:

But the Variables part, I could not find a consensus, and I created from more than I think even right ...

Project Structure:

The standard structure of each project would be: ./src ./src/constant ./src/modules ./src/data ./src/data/general.py ./src/main.py ./README(.txt/.rst/.md) ./LICENSE ./project_info ./config ./docs ./test

Explanation of the directories:
./ project_info
  Contains information about the project, such as version, requirements.txt, error log, etc ...

./ src
  Directory with everything the project needs.   In addition to containing the dirs [data], [constant], [modules], contains all the   scripts that have (all major scripts):

if __init__ == "__main__":
    ...

./ config
  Contains configuration files, eg: SQL configuration, etc ...

./ src / data
  It contains all the data files the project could need, such as .png's, .csv's, etc ...

./ src / constant
  Contains python scripts containing only variable declarations

./ src / modules
  Contains all the modules (.py's, .libs, etc ...) used by the program

./ test
  Contains all test scripts

./docs
  Contains all project documentation

Variables and Files

### Naming Variables:
Class (es): UpperCamelCase.
Example (s):
  MetaServer
  Process
  ProcessGenerator
  WriterOfStuff

Method (s) / Function (s): lowerCamelCase.
Example (s):
  createServer (...)
  writeToFile (...)
  createHeatMap (...)

Constant (s): CAPSLOCK, words divided by underscore, prefixed with PUBLIC or PRIVATE    Example (s):
  SQL_PASSWORD = PUBLIC_DIR + "1234"
  SQL_HOST = PUBLIC_DIR + "0: 0: 0: 0"
  SERVER_KEY = PUBLIC_DIR + "12345"
  HAARCASCADE = PRIVATE_DIR + "haarcascade.xml"
Note: PRIVATE_DIR and PUBLIC_DIR should be declared within constant / general.py
Note (2): The idea of PRIVATE_DIR would be some directory inside the folder of my program, where a more lay user would have "difficult" access. While PUBLIC_DIR would be something equivalent to% APPDATA% in Windows, or ~ / home in Ubuntu, etc ...

Data File (s): lowercase, words divided by underscore
Example (s):
  haarcascade_frontalface_default.xml
  log.txt
  smile.png
  file.csv

Python Script (s): lowercase, words divided by underscore
Example (s):    main.py
   server.py
   webcam_server.py

### Declaring Variables:

Class (es): within class_name.py
Example (s):
  MetaServer class inside meta_server.py
  class Process inside process.py
  ProcessGenerator class inside process_generator.py
  class WriterOfStuff inside writer_of_stuff.py

Constant (s): within constant / *. py
Example (s):
  SQL_PASSWORD within constant / sql.py
  SQL_HOST inside constant / sql.py
  SERVER_KEY inside constant / server.py
  HAARCASCADE within constant / general.py

Data File (s): within src / data or some subdirectory of src / data
Example (s):
  src / data / haarcascade.xml
  src / data / log.txt
  smile.png
  src / data / csv / file.csv

Python Script: within src / modules or some subdirectory of src / modules
Example (s):
  src / modules / server.py
  src / modules / webcam_server.py
  src / modules / heatmap / load.py
Note: less main.py, this is within ./src

Voices Feedback

So, I really wanted to hear your opinion about how I plan to organize my company's projects, which would all be in this pattern ...
Is There Anything You Think I Should Change?
Maybe pass ./ src / data to ./date , I do not know

Thank you in advance for the help
And sorry for the huge question heh

    
asked by anonymous 04.05.2018 / 15:18

0 answers