|
1 | 1 | Python Standard Library List
|
2 | 2 | ----------------------------
|
3 | 3 |
|
4 |
| -This package includes lists of all of the standard libraries for versions of Python ``>=`` 2.6, along with the code for scraping the official Python docs to get said lists. |
| 4 | +This package includes lists of all of the standard libraries for Python 2.6, 2.7, 3.2, 3.3, and 3.4, along with the code for scraping the official Python docs to get said lists. |
| 5 | + |
| 6 | +Listing the modules in the standard library? Wait, why on Earth would you care about that?! |
| 7 | +=========================================================================================== |
| 8 | + |
| 9 | +Because knowing whether or not a module is part of the standard library will come in handy in `a project of mine <https://github.com/jackmaney/pypt>`_. `And I'm not the only one <http://stackoverflow.com/questions/6463918/how-can-i-get-a-list-of-all-the-python-standard-library-modules>`_ who would find this useful. Or, the TL;DR answer is that it's handy in situations when you're analyzing Python code and would like to find module dependencies. |
| 10 | + |
| 11 | +After googling for a way to generate a list of Python standard libraries (and looking through the answers to the previously-linked Stack Overflow question), I decided that I didn't like the existing solutions. |
| 12 | + |
| 13 | +So, I decided to brute force it a bit, by putting together a scraper for the TOC of the standard library page of the official Python docs (eg `here is the page for Python 2.7 <https://docs.python.org/2/library/index.html>`_). |
| 14 | + |
| 15 | +Usage |
| 16 | +===== |
| 17 | + |
| 18 | +The only argument you need to worry about specifying is a (major and minor) version number: |
| 19 | + |
| 20 | +:: |
| 21 | + >>> from stdlib_list import short_versions |
| 22 | + >>> short_versions |
| 23 | + ['2.6', '2.7', '3.2', '3.3', '3.4'] |
| 24 | + |
| 25 | +Or, if you prefer, an exact version of one of the standard library pages that I scraped: |
| 26 | + |
| 27 | +:: |
| 28 | + |
| 29 | + >>> from stdlib_list import long_versions |
| 30 | + >>> long_versions |
| 31 | + ['2.6.9', '2.7.9', '3.2.6', '3.3.6', '3.4.3'] |
| 32 | + |
| 33 | +With that in mind, here's how you can grab a list of standard libraries: |
| 34 | + |
| 35 | +:: |
| 36 | + >>> from stdlib_list import stdlib_list |
| 37 | + >>> libraries = stdlib_list("2.7") |
| 38 | + >>> libraries[:10] |
| 39 | + ['AL', 'BaseHTTPServer', 'Bastion', 'CGIHTTPServer', 'ColorPicker', 'ConfigParser', 'Cookie', 'DEVICE', 'DocXMLRPCServer', 'EasyDialogs'] |
| 40 | + |
| 41 | +Installation |
| 42 | +============ |
| 43 | + |
| 44 | +The easy way is via ``pip``: |
| 45 | + |
| 46 | +:: |
| 47 | + pip install stdlib_list |
| 48 | + |
| 49 | +The hard way is to clone this repository, go into the directory into which you cloned this repo, and do a |
| 50 | + |
| 51 | +:: |
| 52 | + python setup.py install |
| 53 | + |
| 54 | + |
| 55 | +Caveats |
| 56 | +======= |
| 57 | + |
| 58 | +* No attempt was made to cull deprecated libraries. I just scraped the standard library page for the relevant version. |
| 59 | + |
| 60 | +* For the sake of completion, if ``A.B`` is in the list, I also threw in ``A`` (eg, you'll find ``xml``, ``xml.etree``, and ``xml.etree.ElementTree`` in the list, even though ``xml`` isn't specifically listed in the TOC). |
| 61 | + |
| 62 | +The Scraper |
| 63 | +=========== |
| 64 | + |
| 65 | +You shouldn't need to fiddle around with the scraper, but in case you want to (or in case the Python Software Foundation decides to change the page layout of the standard library TOC page), just do: |
| 66 | + |
| 67 | +:: |
| 68 | + from stdlib_list import scraper |
| 69 | + scraper.scrape("2.7") # Scrape for 2.7 only (for debugging, mainly) |
| 70 | + scraper.scrape() # Scrape for all versions listed above. |
| 71 | + |
| 72 | +LICENSE |
| 73 | +======= |
| 74 | + |
| 75 | +The MIT License (MIT) |
| 76 | + |
| 77 | +Copyright (c) 2015 Jack Maney |
| 78 | + |
| 79 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 80 | +of this software and associated documentation files (the "Software"), to deal |
| 81 | +in the Software without restriction, including without limitation the rights |
| 82 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 83 | +copies of the Software, and to permit persons to whom the Software is |
| 84 | +furnished to do so, subject to the following conditions: |
| 85 | + |
| 86 | +The above copyright notice and this permission notice shall be included in all |
| 87 | +copies or substantial portions of the Software. |
| 88 | + |
| 89 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 90 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 91 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 92 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 93 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 94 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 95 | +SOFTWARE. |
0 commit comments