Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39382

Re: improving performance of writing into a pipe

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.86.MISMATCH!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'exception': 0.03; 'except:': 0.07; 'try:': 0.07; 'python': 0.09; 'ioerror:': 0.09; 'raised.': 0.09; 'sep': 0.09; 'subject:into': 0.09; 'cc:addr :python-list': 0.10; '2.7.3': 0.16; 'cc:name:python list': 0.16; 'cryptic': 0.16; 'doing,': 0.16; 'file).': 0.16; 'for,': 0.16; 'subject:writing': 0.16; 'try/except': 0.16; 'utc,': 0.16; 'wrote:': 0.17; '(in': 0.18; '>>>': 0.18; 'written': 0.20; '"",': 0.22; 'cc:2**0': 0.23; 'example': 0.23; 'this:': 0.23; '(this': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'wrote': 0.26; '(most': 0.27; 'am,': 0.27; 'errors.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'lines': 0.28; 'received:209.85.212': 0.28; 'this.': 0.29; 'error': 0.30; 'code': 0.31; 'file': 0.32; 'running': 0.32; 'print': 0.32; 'message.': 0.33; 'traceback': 0.33; 'code:': 0.33; 'received:google.com': 0.34; 'said,': 0.35; 'saved': 0.35; 'received:209.85': 0.35; 'michael': 0.36; 'but': 0.36; 'useful': 0.36; 'should': 0.36; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'nothing': 0.38; 'gives': 0.39; 'remove': 0.61; 'telling': 0.61; '(that': 0.62; 'email addr:gmail.com': 0.63; 'more': 0.63; 'show': 0.63; 'believe': 0.69; 'information:': 0.74; '2013': 0.84; 'case?': 0.84; 'directory:': 0.84; 'oscar': 0.84; 'resistant': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=Ir7jy+FA/njdSa9RWdTtMw+4JhBG4167PUpFE5XGSWY=; b=hcEE0aMCqJCEqfuQLXGXE9sSjs/FTAAjjsi0hUlw/b/qW1WjMO3l12zqTyx9kBn6Bc u+4IU1tM3FM/+gkO7FXEu/keUPqyDaRXqIkSMzjFkJ49ucBgWSh8Pjo1K9WR5WvIZLa0 961DqhEO3ohBsuOTDz3StBcd6eW2PxH+MDlWUvw1CINT51s15d0qMxBhfZTA/Yzpr+6i X4PluSMCg3OEe46gwce72H/BZ43zEjijiqT436iuos/d4kaApKYXgZgwxald9UTs/Ek1 DF2HpqKB0qesDXOC+RyyNnNVhSKEzwVU2XIVddA7Yro9WEcDvLeVinSxJN4/tbakl5RC EtNw==
X-Received by 10.52.71.235 with SMTP id y11mr24054722vdu.43.1361397957741; Wed, 20 Feb 2013 14:05:57 -0800 (PST)
MIME-Version 1.0
In-Reply-To <c6cb8e06-b7c1-474e-bc1e-e2f2733e477f@googlegroups.com>
References <76620a9e-45fe-499d-b1bf-06b1d2a91c25@googlegroups.com> <mailman.1952.1361200943.2939.python-list@python.org> <16e85bd1-6e5d-4d70-95bf-cc6b986a9f7c@googlegroups.com> <kftm2l$b84$1@r03.glglgl.gl> <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 Wed, 20 Feb 2013 22:05:37 +0000
Subject Re: improving performance of writing into a pipe
To mikprog@gmail.com
Content-Type text/plain; charset=ISO-8859-1
Cc Python List <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.2131.1361397960.2939.python-list@python.org> (permalink)
Lines 53
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1361397960 news.xs4all.nl 6978 [2001:888:2000:d::a6]:46993
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:39382

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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