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
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
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
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
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
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
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
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
.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.
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
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()
&
__(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:
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
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
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
15 matches
Mail list logo