On 2 February 2016 at 06:39, Andrew Barnert via Python-Dev <python-dev@python.org> wrote: > On Feb 1, 2016, at 09:59, mike.romb...@comcast.net wrote: >> >> If the stdlib were to use implicit namespace packages >> ( https://www.python.org/dev/peps/pep-0420/ ) and the various >> loaders/importers as well, then python could do what I've done with an >> embedded python application for years. Freeze the stdlib (or put it >> in a zipfile or whatever is fast). Then arrange PYTHONPATH to first >> look on the filesystem and then look in the frozen/ziped storage. > > This is a great solution for experienced developers, but I think it would be > pretty bad for novices or transplants from other languages (maybe even > including Python 2). > > There are already multiple duplicate questions every month on StackOverflow > from people asking "how do I find the source to stdlib module X". The > canonical answer starts off by explaining how to import the module and use > its __file__, which everyone is able to handle. If we have to instead explain > how to work out the .py name from the qualified module name, how to work out > the stdlib path from sys.path, and then how to find the source from those two > things, with the caveat that it may not be installed at all on some > platforms, and how to make sure what they're asking about really is a stdlib > module, and how to make sure they aren't shadowing it with a module elsewhere > on sys.path, that's a lot more complicated. Especially when you consider that > some people on Windows and Mac are writing Python scripts without ever > learning how to use the terminal or find their Python packages via > Explorer/Finder.
For folks that *do* know how to use the terminal: $ python3 -m inspect --details inspect Target: inspect Origin: /usr/lib64/python3.4/inspect.py Cached: /usr/lib64/python3.4/__pycache__/inspect.cpython-34.pyc Loader: <_frozen_importlib.SourceFileLoader object at 0x7f0d8d23d9b0> (And if they just want to *read* the source code, then leaving out "--details" prints the full module source, and would work even if the standard library were in a zip archive) Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com