Re: PyWhich

2011-08-05 Thread Steven D'Aprano
Billy Mays wrote: > The reason I used stdout was because I was going to be using it in a > tool chain where the stdout might need to be formatted for another > program to read in. print writes to sys.stdout unless you tell it different. >>> import sys >>> import StringIO >>> capture = StringIO.S

Re: PyWhich

2011-08-05 Thread Billy Mays
On 08/04/2011 10:03 PM, Chris Angelico wrote: On Fri, Aug 5, 2011 at 1:34 AM, Steven D'Aprano wrote: Especially for a tool aimed at programmers (who else would be interested in PyWhich?) The use that first springs to my mind is debugging import paths etc. If you have multiple py

Re: PyWhich

2011-08-05 Thread John Gordon
In <4e3bf554$0$29976$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano writes: > Doh! I *always* conflate env and which. Thank you for the correction. Way to say "conflate"! :-) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for B

Re: PyWhich

2011-08-05 Thread Tim Golden
On 05/08/2011 14:51, Steven D'Aprano wrote: Tim Chase wrote: On 08/04/2011 07:34 PM, Steven D'Aprano wrote: Billy Mays wrote: #!/usr/bin/python I believe the recommended, platform independent hash-bang line is #!/usr/bin/which python I think you mean #!/usr/bin/env python Doh! I

Re: PyWhich

2011-08-05 Thread Steven D'Aprano
Tim Chase wrote: > On 08/04/2011 07:34 PM, Steven D'Aprano wrote: >> Billy Mays wrote: >>> #!/usr/bin/python >> >> I believe the recommended, platform independent hash-bang line is >> >> #!/usr/bin/which python > > I think you mean > >#!/usr/bin/env python Doh! I *always* conflate env and

Re: PyWhich

2011-08-04 Thread Chris Angelico
On Fri, Aug 5, 2011 at 1:34 AM, Steven D'Aprano wrote: > Especially for a tool aimed at programmers (who else would be interested in > PyWhich?) The use that first springs to my mind is debugging import paths etc. If you have multiple pythons installed and aren't sure that the

Re: PyWhich

2011-08-04 Thread Tim Chase
On 08/04/2011 07:34 PM, Steven D'Aprano wrote: Billy Mays wrote: #!/usr/bin/python I believe the recommended, platform independent hash-bang line is #!/usr/bin/which python I think you mean #!/usr/bin/env python -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWhich

2011-08-04 Thread Steven D'Aprano
on. I would recommend not catching ImportError at all, and just let the standard Python error handling print the traceback. Especially for a tool aimed at programmers (who else would be interested in PyWhich?), hiding useful diagnostic errors and replacing them with a generic, and potentially wrong, message, is very bad. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWhich

2011-08-04 Thread Dan Stromberg
.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.

Re: PyWhich

2011-08-04 Thread Tim Chase
t;UNKNOWN") )) except ImportError: stderr.write("No such module '%s'\n" % modname) else: stderr.write("Usage: pywhich [...]\n") I don't know a good way to tap into other import hooks (such as the zipfile import) to augment that type_map dictionary. -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWhich

2011-08-04 Thread Chris Rebert
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 \n") >        sys.stderr.flush() &

PyWhich

2011-08-04 Thread Billy Mays
__(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:

Re: pywhich script - where is that module?

2004-12-17 Thread Dennis Benzinger
Thomas Guettler wrote: > [...] > Nice, you could add it to the python cookbook. > [...] Just in the case the OP doesn't know where to find the cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/ -- http://mail.python.org/mailman/listinfo/python-list

Re: pywhich script - where is that module?

2004-12-17 Thread Thomas Guettler
Am Fri, 17 Dec 2004 09:09:25 + schrieb Keith Dart: > Have you ever wondered where your python modules get imported from? > Here is a little script, called "pywhich", that will tell you. Nice, you could add it to the python cookbook. Thomas -- Thomas Güttler, h

pywhich script - where is that module?

2004-12-17 Thread Keith Dart
Have you ever wondered where your python modules get imported from? Here is a little script, called "pywhich", that will tell you. -- \/ \/ (O O) -- oOOo~(_)~oOOo Keith Da