r/programming • • Nov 03 '19

Why you should use `python -m pip`

https://snarky.ca/why-you-should-use-python-m-pip/
0 Upvotes

13 comments sorted by

View all comments

2

u/cyanrave Nov 03 '19

Good advice I guess? I'd rather see people using '-m' to advocate instead for better test execution instead of pip stuff.

If you use subpackaging correctly, with relative imports and the like, this flag really helps. If you're still dumping tests under a 'tests' directory at the root of the project in py3... don't do that.

4

u/[deleted] Nov 03 '19

Can you please elaborate on that bit about tests in project root? Not sure I understand what you mean by that. Thx.

3

u/cyanrave Nov 04 '19 edited Nov 04 '19

People consistently plop a folder called 'tests' right next to the package they'd like to test... which is code that describes the expected behavior of the code next door.

I believe it may be the single biggest mistake that people are bringing forward into py3 when they migrate. Subpackaging and implicit name spacing are alive and well in py3 and people still habitually go towards what the the pytest docs says 'because it is pytest'.

Shortly into Okken's modern book on the pytest framework, he clears up this sorry note that exists in the 'official docs', clearly formulating why using subpackaging has organizational advantages.

2

u/[deleted] Nov 04 '19

Ok, will have to revisit Okken's book. Still not sure I understand what organizational paradigm you propose to use.

2

u/cyanrave Nov 04 '19

When I get to work, I'll see if I can rip a quote from him on it.