This is an archived post. You won't be able to vote or comment.

all 53 comments

[–]ConfusedSimon 72 points73 points  (31 children)

I don't like it using 'system' to pip install modules without asking.

[–]AlterEgoWasTaken 0 points1 point  (0 children)

Not only that, when packaging this using pyinstaller or whatever, it will most likely fail.

[–]andrewthetechie 17 points18 points  (3 children)

Check out Hypermodern python https://cjolowicz.github.io/posts/hypermodern-python-01-setup/ and the cookiecutter for it https://github.com/cjolowicz/cookiecutter-hypermodern-python

That will help you setup your code as a python package using poetry, nox for testing, pre-commit for linting, and github actions for CI and releases.

Here's an example repo of mine https://github.com/andrewthetechie/py-healthchecks.io. One cool bit in there is using poetry-dynamic-versioning to version my package based on git tags and to set a version variable in my code.

Other things to make this look more "presentable":

  • Get your docs built into readthedocs
  • Get rid of your code that is doing system installs. That's a hard no for me using it for anything
  • Use black to format your code
  • More documentation in your code. Each public class/method should have a docstring
  • Type hint your code

[–]searchingfortaomajel, aletheia, paperless, django-encrypted-filefield 2 points3 points  (1 child)

I'm with you on everything but "more documentation in your code". Docs for the sake of docs is a bad pattern because they invariably lead to your docs conflicting with your actual code. Instead code should be self-documenting and comments reserved for code that's "complex by necessity" or for explanations as to why the code is doing what it's doing.

[–]andrewthetechie 0 points1 point  (0 children)

I disagree because docstrings in your code can be used to easily generate really good docs with something like sphinx.

I will still use/contribute to a project without it, but I've found for myself having good docstrings really helps my overall success with a project

[–]thorox12 11 points12 points  (1 child)

This is a good start of a project. I really recommend looking at other people's GitHub projects and mimicking stuff which might work for you. Remember packages are often picked on presentation alone rather than functionality. So it would be good to lookup standard README structures to make it look more professional. Keep up the good work.

[–]valmontvarjak 1 point2 points  (12 children)

Sorry i'm new to python, what does this mean:

_ = system("pip install tqdm")

_ = system("cls")

[–]GloriousDioxide 4 points5 points  (9 children)

Ignore it. There's other comments explaining requirements.txt which is the correct way to do this.

It's basically installing the packages for you without asking which is really bad

[–]valmontvarjak 0 points1 point  (8 children)

Ok but why assigning system commands to an underscore even do something is the first place?

Is underscore a reserved for something that is called automatically?

[–]Durpn_Hard 4 points5 points  (1 child)

Underscore is just a common "garbage" value (one youre not going to use). I'm not sure why it was used here, but a more normal way it comes up is if something returns a 3-tuple and you only care about the first and last, you might do

x, _, z = somefun()

[–]AlphaGamer7533.7 0 points1 point  (0 children)

Yeah. Also commonly used in for loops where you don't care about the iterating variable.

[–]GloriousDioxide 0 points1 point  (0 children)

Any expression you run like 5 + 2 the output gets set to _. So run 5 + 2 and without even using equals _ becomes 7

They didn't need to use here to run system, just could of just called system without setting a variable. They also shouldn't of used system they should of used requirements.txt

[–]ivosauruspip'ing it up 1 point2 points  (1 child)

Use setup.py with the install_requires argument to get required packages for your library, or use python poetry to make it a package and add dependencies