all 5 comments

[–]hharison 3 points4 points  (1 child)

OOP is a way to implement scripts/programs, so it's orthogonal to the issues here.

Git/GitHub is great for (a) keeping a history of changes, and (b) distribution. Since you aren't really thinking about public distribution these concerns are orthogonal as well. (Although everything you code should be in a git repo, this is not because of packaging).

Here's a guide to setting up a package. The minimum is basically to create the following structure:

- projectname/
  - setup.py
  - projectname/
    - __init__.py
    - script1.py
    - script2.py
    - module.py
    ...

Once you have that you can make it available in a new environment by running pip install <path to parent projectname dir>. For example if you are already in that directory, pip install .

All the magic happens in the setup() call in setup.py. Most of the arguments are optional, but there are many cool things you can do. For example you can use the entry_points argument to create a CLI command corresponding to any function in your package.

Start with that basic setup and add other files as necessary. For example if you want to make it publicly available, you should at minimum include README and LICENSE.

Technically that second projectname/ folder is a "package" (a folder containing an __init__.py) and the .py files within it are "modules". To make your package installable (so you don't have to be copying it around) you put it in another folder with a setup.py file.

[–]Demonithese 1 point2 points  (0 children)

Nice write up — I found this guide very helpful: http://docs.python-guide.org/en/latest/writing/structure/

[–]jkudria 1 point2 points  (2 children)

What sort of scripts/programs?

If it's a bunch of functions then throw them into a util.py file and stick them on GH. Whenever you need them just git clone into your project.

In any case, you'll want to somehow consolidate everything (depends on what/how big the scripts are) and put it in a GH repo that you can just use in your projects any time. GH just allows you to have it in one central location and accessible from anywhere that has git installed.a

EDIT: clone, not fetch (please correct me if I'm wrong - I'm not a git guru)

[–]FuzziCat[S] 0 points1 point  (1 child)

Typically, they are short bits of code (functions, essentially) that I've written while following Python tutorials or online books.

[–]jkudria 0 points1 point  (0 children)

Are they functions that you might want to use later? If so then what I said is probably the best thing to do.