Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10865
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.wiretrip.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'sys': 0.05; 'importerror:': 0.07; 'python': 0.08; '__name__': 0.09; 'am,': 0.13; 'wrote:': 0.15; '\'%s\'\\n"': 0.16; "'\\n')": 0.16; "'__main__':": 0.16; 'billy': 0.16; '\xc2\xa0if': 0.16; 'cc:addr :python-list': 0.16; 'aug': 0.19; 'cheers,': 0.19; 'wrote': 0.21; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply- To:1': 0.22; 'hey': 0.26; 'skip:_ 20': 0.28; 'thu,': 0.28; 'message-id:@mail.gmail.com': 0.28; 'import': 0.29; 'script': 0.29; 'cc:addr:python.org': 0.30; 'module': 0.30; 'skip:\xc2 20': 0.30; 'seem': 0.31; 'chris': 0.32; 'anyone': 0.33; 'skip:# 10': 0.34; "can't": 0.34; 'file': 0.36; 'anything': 0.37; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85.161': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; '8bit%:8': 0.38; 'think': 0.38; 'received:209': 0.40; 'your': 0.60; 'skip:\xc2 10': 0.74; 'sender:addr:chris': 0.84; 'url:rebertia': 0.84; 'to:none': 0.93; 'from.': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:cc:content-type :content-transfer-encoding; bh=a9QH4aToDh8K97ekvjxm6qvVt7LGOrwO7TNG8M/SROE=; b=CLyT8fcRtCs/xJYoGHYntYcYKTlrqHv3gqX+kRRrMJtygbwa5HK3l6jiyGk16w1js+ XTH7CgwPL2VcPz3CFle71celw3BIcEHYEtiHeX4utP4YMT9vuESdEGc0wPcKVu0DVWFO UFMQbm9DDWPk4oiynXDA/j2b23BSv0ZOAdYlI= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <j1e45l$jtg$1@speranza.aioe.org> |
| References | <j1e45l$jtg$1@speranza.aioe.org> |
| Date | Thu, 4 Aug 2011 10:22:43 -0700 |
| X-Google-Sender-Auth | csPLiNZAO4h_-xQeppUYbmGByQg |
| Subject | Re: PyWhich |
| From | Chris Rebert <clp2@rebertia.com> |
| Cc | python-list@python.org |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1895.1312478566.1164.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1312478566 news.xs4all.nl 23850 [2001:888:2000:d::a6]:45592 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:10865 |
Show key headers only | View raw
On Thu, Aug 4, 2011 at 5:43 AM, Billy Mays
<81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> wrote:
> Hey c.l.p.,
>
> I wrote a little python script that finds the file that a python module came
> from. Does anyone see anything wrong with this script?
>
>
> #!/usr/bin/python
>
> import sys
> if __name__ == '__main__':
> if len(sys.argv) > 1:
> try:
> m = __import__(sys.argv[1])
> sys.stdout.write(m.__file__ + '\n')
> sys.stdout.flush()
> sys.exit(0)
> except ImportError:
> sys.stderr.write("No such module '%s'\n" % sys.argv[1])
> sys.stderr.flush()
> sys.exit(1)
> else:
> sys.stderr.write("Usage: pywhich <module>\n")
> sys.stderr.flush()
> sys.exit(0)
Nothing wrong per se, but the flush()es seem unnecessary, and why do
stdout.write() when you can just print()?
Cheers,
Chris
--
I can't not think of the pitchman when I read your posts...
http://rebertia.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PyWhich Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> - 2011-08-04 08:43 -0400
Re: PyWhich Chris Rebert <clp2@rebertia.com> - 2011-08-04 10:22 -0700
Re: PyWhich Tim Chase <python.list@tim.thechases.com> - 2011-08-04 13:24 -0500
Re: PyWhich Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-05 10:34 +1000
Re: PyWhich Tim Chase <python.list@tim.thechases.com> - 2011-08-04 20:04 -0500
Re: PyWhich Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-05 23:51 +1000
Re: PyWhich Tim Golden <mail@timgolden.me.uk> - 2011-08-05 15:03 +0100
Re: PyWhich John Gordon <gordon@panix.com> - 2011-08-05 14:33 +0000
Re: PyWhich Chris Angelico <rosuav@gmail.com> - 2011-08-05 03:03 +0100
Re: PyWhich Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> - 2011-08-05 10:43 -0400
Re: PyWhich Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-06 00:56 +1000
Re: PyWhich Web Dreamer <webdreamer@nospam.fr> - 2011-08-05 16:34 +0200
csiph-web