[Python-ideas] sys.path is a hack - bringing it back under control

julien tayon julien at tayon.net
Mon Feb 20 15:28:57 CET 2012


Hello,

I am a bit confused. Tests are best not located amongst code, but in a
sub directory. I was strongly stated on #python to use  unittest(2) or
nose in order not to use the path hacks.

so did stackoverflow also stated when I googled it :
http://stackoverflow.com/questions/61151/where-do-the-python-unit-tests-go

Okay unittest tries relative import by adding a dot in front of the
name, but in the fallback, in the end, does not it uses the sys path
hack ? (my eyes may be old, my brain damaged by alcohol, but it looks
very much this way).

It looks like   hiding dust under the carpet, and stating that by
tabooing sys.path hack use and locating it in very savant module, the
problem gets solved.

I am honestly, just very candid on this one, and pretty puzzled.

sys path hack, looks to me a lot  like coupling between classes,
global varaibles, or gotos, and other beasts. It may be needed and yet
powerful therefore great wisdom is needed to handle them carefully.

PS (not sure I am 100% serious after this point)

Why not create a module like __use_wisefully__ then ?
people would be warned by being compelled to write :

from __use_wisefully__ import sys.path ?


Cheers,
-- 
Jul



More information about the Python-ideas mailing list