Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75378
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <skip.montanaro@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'else:': 0.03; 'filename:fname piece:py': 0.07; 'modified': 0.07; 'subject:Getting': 0.07; 'imported': 0.09; 'subject:modules': 0.09; 'trailing': 0.09; 'try:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'wrote': 0.14; '"/"': 0.16; "'__doc__',": 0.16; "'__file__',": 0.16; "'__path__',": 0.16; 'brackets.': 0.16; 'builtins': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'imported.': 0.16; 'programmatic': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'wed,': 0.18; 'module': 0.19; "hasn't": 0.19; 'packages.': 0.19; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'skip': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'getting': 0.31; "skip:' 10": 0.31; "d'aprano": 0.31; 'steven': 0.31; 'file': 0.32; 'stuff': 0.32; 'subject:all': 0.32; 'skip:d 20': 0.34; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'object,': 0.36; 'shows': 0.36; 'charset:us-ascii': 0.36; 'searching': 0.37; 'list': 0.37; 'skip:o 20': 0.38; 'skip:& 10': 0.38; 'skip:[ 10': 0.38; 'skip:& 20': 0.39; 'enclosed': 0.60; 'skip:z 20': 0.60; 'identify': 0.61; 'skip:o 30': 0.61; 'such': 0.63; 'skip:n 10': 0.64; 'more': 0.64; '30,': 0.65; 'within': 0.65; 'jul': 0.74; 'square': 0.74; '2014,': 0.84; 'contains.': 0.84; 'distinguish': 0.84; 'ideas.': 0.84; 'stuff:': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=M1q22BswpLx54jsm+DowWLlwDfWkZGg79dRyyJlyJnM=; b=N6pDjxryx1RR+i/M2+ff8JDMJILmnFFFO1X5DQ5Nv4elUyXP3cdx4HvdtNgCwHt+MU xzqeKztgncn6klGsnfkp3ZwgYisnRmLBMWrlRjXUTDyDHFwIMs8sz4NeGE3JBBpMWwos ELKpYGvh8q1ocsQHTJ/5f/SpufCyXjQ0Dac7RwE6apr2evKmnQ6MW9O4HPj7gv1cjK+N uonHnHc75JjeUsqS9QVVX5PGb5VrBMPXs94a4Q6u9MpsQvNh/0ZnbMtpHGThA1c9iM+C yJpZmo3fYi0WiX2w2VES9uGfD1gB4oeFPMlABQr3poFs0PM5YTL8/UF4nJRtl7vt8ybN gLiQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.164.202 with SMTP id ys10mr8363689igb.6.1406731531300; Wed, 30 Jul 2014 07:45:31 -0700 (PDT) |
| Sender | skip.montanaro@gmail.com |
| In-Reply-To | <53d8a20e$0$29977$c3e8da3$5496439d@news.astraweb.com> |
| References | <53d8a20e$0$29977$c3e8da3$5496439d@news.astraweb.com> |
| Date | Wed, 30 Jul 2014 09:45:30 -0500 |
| X-Google-Sender-Auth | o3NYbE3QTlYqv6MoaXL5Ti2DWVo |
| Subject | Re: Getting a list of all modules |
| From | Skip Montanaro <skip@pobox.com> |
| To | "Steven D'Aprano" <steve@pearwood.info> |
| Content-Type | multipart/mixed; boundary=089e0149490637cfb204ff6a3501 |
| Cc | Python <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12440.1406731534.18130.python-list@python.org> (permalink) |
| Lines | 116 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1406731534 news.xs4all.nl 2948 [2001:888:2000:d::a6]:59521 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:75378 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Wed, Jul 30, 2014 at 2:43 AM, Steven D'Aprano <steve@pearwood.info> wrote: > I'm looking for a programmatic way to get a list of all Python modules > and packages. Not just those already imported, but all those which > *could* be imported. > I wrote a modified dir(), which I inject into builtins in interactive sessions. When getting a directory of an object, it attempts to identify not-yet-imported modules it contains. Such modules are enclosed in square brackets. Modules that smell like packages also get a trailing '/'. For example: % python Python 2.7.5+ (2.7:2921f6c2009e, Apr 30 2014, 14:00:13) [GCC 4.4.6 [TWW]] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import dateutil >>> dir(dateutil) ['[easter]', '[parser]', '[relativedelta]', '[rrule]', '[tz]', '[tzwin]', '[zoneinfo/]', '__author__', '__builtins__', '__doc__', '__file__', '__license__', '__name__', '__package__', '__path__', '__version__'] It's not perfect, but works for my needs. Perhaps it will give you some ideas. Skip
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Getting a list of all modules Steven D'Aprano <steve@pearwood.info> - 2014-07-30 07:43 +0000
Re: Getting a list of all modules Chris Angelico <rosuav@gmail.com> - 2014-07-30 18:33 +1000
Re: Getting a list of all modules Peter Otten <__peter__@web.de> - 2014-07-30 10:46 +0200
Re: Getting a list of all modules Robert Kern <robert.kern@gmail.com> - 2014-07-30 11:35 +0100
Re: Getting a list of all modules Leo Jay <python.leojay@gmail.com> - 2014-07-30 21:22 +0800
Re: Getting a list of all modules Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-31 10:41 +0000
Re: Getting a list of all modules Roy Smith <roy@panix.com> - 2014-07-31 07:55 -0400
Re: Getting a list of all modules Chris Angelico <rosuav@gmail.com> - 2014-07-31 23:13 +1000
Re: Getting a list of all modules Terry Reedy <tjreedy@udel.edu> - 2014-07-31 15:59 -0400
Re: Getting a list of all modules Robert Kern <robert.kern@gmail.com> - 2014-08-01 14:39 +0100
Re: Getting a list of all modules Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-01 15:41 +0000
Re: Getting a list of all modules jonnicoll11@googlemail.com - 2014-08-02 14:13 -0700
Re: Getting a list of all modules Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-02 22:22 +0100
Re: Getting a list of all modules Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-03 14:38 +0100
Re: Getting a list of all modules Chris Angelico <rosuav@gmail.com> - 2014-07-30 23:27 +1000
Re: Getting a list of all modules wxjmfauth@gmail.com - 2014-07-30 06:42 -0700
Re: Getting a list of all modules Ian Kelly <ian.g.kelly@gmail.com> - 2014-07-30 08:29 -0600
Re: Getting a list of all modules Skip Montanaro <skip@pobox.com> - 2014-07-30 09:45 -0500
Re: Getting a list of all modules Akira Li <4kir4.1i@gmail.com> - 2014-07-31 22:55 +0400
Bug with help (was Re: Getting a list of all modules) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-31 20:19 +0100
Re: Bug with help (was Re: Getting a list of all modules) Terry Reedy <tjreedy@udel.edu> - 2014-07-31 16:15 -0400
Re: Bug with help (was Re: Getting a list of all modules) Akira Li <4kir4.1i@gmail.com> - 2014-08-02 06:17 +0400
Re: Bug with help (was Re: Getting a list of all modules) Heinz Schmitz <HeinzSchmitz@gmx.net> - 2014-08-02 10:33 +0200
Re: Bug with help (was Re: Getting a list of all modules) Robert Kern <robert.kern@gmail.com> - 2014-08-02 13:13 +0100
Re: Bug with help (was Re: Getting a list of all modules) Terry Reedy <tjreedy@udel.edu> - 2014-08-02 14:17 -0400
csiph-web