[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

__file__ is a disease

Le samedi 30 janvier 2010 à 21:40 +0100, Pietro Battiston a écrit : 
> In my ignorance, what I've exposed is the only way I know to get things
> working as I want, so I'll be happy to get in touch with better
> designs... for me, so far, __file__ may very well have been a hack, but
> certainly not a plague.

Maybe you don’t understand it is a plague, because you are not trying to
package the things you write with __file__ for a distribution. The
location of module files on the system should be a hidden implementation
detail. Because of __file__, it is not and this implementation detail
has to be exposed by packaging tools, restricting what they can do in
ways you don’t imagine, making it impossible to just abstract them
behind the “module” concept - which is the only one that should matter
for a programmer.

Python is the only widespread high-level language to do that. I’ve never
seen a Perl, Java or C# module look for its installation path before
deciding what to do. In these languages, modules are abstract objects
and you can do whatever you want with them on the filesystem without
changing any line of code. Believe me, I love the Python language, but
the interpreter is plagued with such issues.

Going back to the topic, please try using autoconf, waf or even cmake to
distribute your modules. These tools were designed to abstract things
like filesystem locations and to generate everything needed at
installation time. Python-specific tools like setuptools are not able to
do that, not unless you bundle specific scripts with your packages.

 .''`.      Josselin Mouette
: :' :
`. `'   “I recommend you to learn English in hope that you in
  `-     future understand things”  -- Jörg Schilling

Attachment: signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=

Reply to: