[Python-ideas] Move Demo scripts under Lib

Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Oct 26 16:50:57 CEST 2010

On Tue, Oct 26, 2010 at 10:15 AM, M.-A. Lemburg <mal at egenix.com> wrote:
> Calling a stdlib package "demo" or "example" is not a good idea,
> since those are rather common package names in existing
> applications.
Since proposed "demo" package is not intended to be imported by
applications, there is not a problem if they are shadowed by
application modules.  There are plenty of common names in the stdlib.
I don't remember this cited as a problem in the past.  For example,
recently added collections and subprocess modules were likely to
conflict with names used by applications.   The "test" package has
been installed with stdlib for ages and it often conflicts with user
test packages.

I believe applications commonly using a "demo" or "example" package is
an argument for rather than against my idea.  (What's good for users
is probably good for stdlib.)

Finally, if the name conflict is indeed an issue, it is not hard to
come up with a less common name: "pydemo", "python_examples", etc.

> I also don't really see the point in moving *scripts* to the stdlib.

I gave three reasons in my first post.  The first is specifically for
*scripts*: to be able to run them using python -m without having to
know an obscure path or polluting system path.

> The lib modules are usually not executable or meant for execution
> and you'd normally expect scripts to be under .../bin rather than
> .../lib.

Most of stdlib modules are in fact executable with python -m.  Just
grep for 'if __name__ == "__main__":' line.  While most demo scripts
are self-contained programs, many are examples on how to write modules
or classes.  See for example Demo/classes.  Furthermore, while users
can run demos, presumably the main purpose of demos is to present the
source code in them.  I believe it is more natural too look for python
source code along PYTHONPATH than along PATH.

I don't think any demo scripts are suitable to be installed under
.../bin.   In fact, Red Hat distribution installs them under

> Why don't you turn the ones you find useful into PyPI packages
> to install separately ?

That's a good way to make them *less* discoverable than they currently
are and make even fewer distributions include them by default.

BTW, what is the purpose of the "Demo" directory to begin with?  I
would naively assume that it is the place where new users would look
to get the idea of what they can do with python.  If this is the case,
it completely misses the target because new users are unlikely to have
a source distribution or look under  /usr/lib/pythonX.Y/Demo or other
system specific place.

More information about the Python-ideas mailing list