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 pythons install

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 they're finding the rig

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
Billy Mays 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? Yes -- the most screamingly obvious question has to be, why are you writing directly to sys.stdout instead of just using pri

Re: PyWhich

2011-08-04 Thread Dan Stromberg
On Thu, Aug 4, 2011 at 10:22 AM, Chris Rebert wrote: > > > #!/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

Re: PyWhich

2011-08-04 Thread Tim Chase
On 08/04/2011 07:43 AM, Billy Mays 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:

Re: PyWhich

2011-08-04 Thread Chris Rebert
On Thu, Aug 4, 2011 at 5:43 AM, Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9...@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 > > impor

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, http://www.thomas-guettler.de