Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39382
| References | (4 earlier) <8f26ac4d-4732-46ac-bf4e-877696b22241@googlegroups.com> <mailman.1958.1361211131.2939.python-list@python.org> <85cd2254-0800-4448-9117-9175bbfd10f6@googlegroups.com> <mailman.2055.1361296049.2939.python-list@python.org> <c6cb8e06-b7c1-474e-bc1e-e2f2733e477f@googlegroups.com> |
|---|---|
| From | Oscar Benjamin <oscar.j.benjamin@gmail.com> |
| Date | 2013-02-20 22:05 +0000 |
| Subject | Re: improving performance of writing into a pipe |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2131.1361397960.2939.python-list@python.org> (permalink) |
On 20 February 2013 17:54, <mikprog@gmail.com> wrote:
> On Tuesday, February 19, 2013 5:47:16 PM UTC, Michael Torrie wrote:
>> On 02/19/2013 02:24 AM, mikprog@gmail.com wrote:
>>
>> > Or rather: what would you try to catch in this particular case?
>>
>>
>> As Peter said, nothing for now. But you seem very resistant to telling
>>
>> us what exception was raised.
>
>
> Michael believe me:
> I am not resistant or try to hide anything!
> As written before, I don't know what exception to search for, so I wrote the (wrong) code:
> except:
> print "error"
> Let's why I don't have a clue about it.
> But someone already explained me that I should not do this.
You don't need to look for errors. If you remove the try/except then
they show up automatically. For example (in the interpreter):
$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> open('Desktop')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 21] Is a directory: 'Desktop'
The last three lines above are the error message that people were
expecting you to show here. They contains lots of useful information:
1) The type of the error
2) A message "Is a directory" and in this case a cryptic code 21 (that
some might find useful).
3) The line of code that caused the error (this is more useful when
running code saved in a file).
What you are doing, however, is this:
>>> try:
... open('Desktop')
... except:
... print('An error occurred...')
...
An error occurred...
Which gives a much less useful error message. So just remove the try/except.
Oscar
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
improving performance of writing into a pipe mikprog@gmail.com - 2013-02-18 07:12 -0800
Re: improving performance of writing into a pipe Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-18 15:21 +0000
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-18 08:31 -0800
Re: improving performance of writing into a pipe Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-02-18 17:49 +0100
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-18 09:00 -0800
Re: improving performance of writing into a pipe Michael Torrie <torriem@gmail.com> - 2013-02-18 11:12 -0700
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 01:24 -0800
Re: improving performance of writing into a pipe Peter Otten <__peter__@web.de> - 2013-02-19 10:55 +0100
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 02:27 -0800
Re: improving performance of writing into a pipe Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-19 11:15 +0000
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 02:27 -0800
Re: improving performance of writing into a pipe Michael Torrie <torriem@gmail.com> - 2013-02-19 10:47 -0700
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-20 09:54 -0800
Re: improving performance of writing into a pipe John Gordon <gordon@panix.com> - 2013-02-20 18:39 +0000
Re: improving performance of writing into a pipe Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-20 22:05 +0000
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-20 09:54 -0800
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 01:24 -0800
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-18 08:31 -0800
Re: improving performance of writing into a pipe Serhiy Storchaka <storchaka@gmail.com> - 2013-02-18 21:29 +0200
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 04:10 -0800
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 04:10 -0800
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 05:39 -0800
Re: improving performance of writing into a pipe Peter Otten <__peter__@web.de> - 2013-02-19 14:57 +0100
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 06:38 -0800
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 06:38 -0800
Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 05:39 -0800
csiph-web