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


Groups > comp.lang.python > #102549

Re: Exception handling for socket.error in Python 3.5/RStudio

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Nathan Hilterbrand <nhilterbrand@gmail.com>
Newsgroups comp.lang.python
Subject Re: Exception handling for socket.error in Python 3.5/RStudio
Date Fri, 5 Feb 2016 15:07:49 -0500
Lines 40
Message-ID <mailman.14.1454702872.2317.python-list@python.org> (permalink)
References <1067e50c-bcbd-464e-8013-754bd66fda91@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de KxsMdQbT839VTs34tM7gagEf6dMqVHQ4P0b3e/BqqX8w==
Return-Path <nhilterbrand@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'subject:Python': 0.05; 'socket': 0.07; 'cc:addr:python- list': 0.09; 'socket.error': 0.09; 'underlying': 0.09; 'python': 0.10; 'syntax': 0.13; '0):': 0.16; '2016': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:handling': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.16; '&gt;': 0.18; 'email addr:gmail.com&gt;': 0.18; 'input': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'file:': 0.22; 'parse': 0.22; 'cc:no real name:2**0': 0.22; 'feb': 0.23; 'tried': 0.24; 'header:In- Reply-To:1': 0.24; 'script': 0.25; 'installed': 0.26; 'error': 0.27; 'message-id:@mail.gmail.com': 0.27; 'looks': 0.29; 'colon': 0.29; 'subject:/': 0.30; 'url:mailman': 0.30; 'error.': 0.31; 'getting': 0.33; 'problem': 0.33; 'url:python': 0.33; 'url:listinfo': 0.34; 'changing': 0.34; 'except': 0.34; 'running': 0.34; 'received:google.com': 0.35; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'missing': 0.37; 'version': 0.38; 'received:209': 0.38; 'skip:p 20': 0.38; 'end': 0.39; 'system.': 0.39; 'url:mail': 0.40; 'still': 0.40; 'close': 0.61; 'press': 0.61; 'here:': 0.63; 'nathan': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=WTRYC85mOuHHzRHDTDsr/DcA53miqmZo4nHuw00M728=; b=UyDuXZfnJvCsLifkkF8aXGOeLzol+9bCfKaAsowCfwv4YHx9TZ8bMvl38H8ZV44YWJ FQbs9NUlWE1oHDSN5cn7LpMwO4JspUvNvPqZsX00/pg3nbeQNOZ0YZrg87mwgLofYK6E xAZ97CRSfNq2aO9+N4W1PDkaRkuwhzliXcdgD33j1mFBY63Gc41my7FZbFk/83MpQ/Ql fbzLQVMyFxZNTJUX7+fWh/85mWDsq8oYO1O8BvnX6tsKvlzSzJcJat+FthWvrXqs2rpk VAcjswk5iv4mMy6VF0PNGhaCJf2gpdLosKSSUQFMhRTEmrj+zolpkQ1DRmPK4lBUUccq 5aPg==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=WTRYC85mOuHHzRHDTDsr/DcA53miqmZo4nHuw00M728=; b=KOQuwt6t+tZdBbRKoHllJfWZ6a/yXyEVUj73SIT0oTefxjkg8UJtpxx02m/QW2K+Dk 1s8Na/kdsgLwYYffcDfwNoHx337kQYeYSPUoXnRQg/FMan7EvCATQqpKhP97GVQhZsVx EYInL+Eum970KsJtKWaCcs/LZYRnuefp+BIv2JDOup+qu1v9CERoH9Gumm4ISCnQHYih 0pSsCP06/T+7Xp3kkMvF2G+6RJmoQ+UIN188zQ/0EkDgj+CtMvr6/2Mv+jwrgidjnJ/u 5Dq7n5I7Xdd4LylEToHr0UFf6WqYBOrDMUvEv0EcVDQtdTSOs4FrWFCu47B8HkvQeBYL WpUA==
X-Gm-Message-State AG10YOSkz/i1b1wlZ+rDYq1brH0KcJAicT61CfaRGV+pThdFExauH7yTTqs51BqybX0lkrN65pjly1LCCQg5Sw==
X-Received by 10.107.198.76 with SMTP id w73mr18608754iof.105.1454702869654; Fri, 05 Feb 2016 12:07:49 -0800 (PST)
In-Reply-To <1067e50c-bcbd-464e-8013-754bd66fda91@googlegroups.com>
X-Content-Filtered-By Mailman/MimeDel 2.1.21rc2
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21rc2
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:102549

Show key headers only | View raw


On Feb 5, 2016 15:01, <shaunak.bangale@gmail.com> wrote:
>
> I am running this python script on R-studio. I have Python 3.5 installed
on my system.
>
> count = 10
> while (count > 0):
>     try :
>         # read line from file:
>         print(file.readline())
>         # parse
>         parse_json(file.readline())
>         count = count - 1
>     except socket.error as e
>         print('Connection fail', e)
>         print(traceback.format_exc())
>
> # wait for user input to end
> # input("\n Press Enter to exit...");
> # close the SSLSocket, will also close the underlying socket
> ssl_sock.close()
> The error I am getting is here:
>
> line 53 except socket.error as e ^ SyntaxError: invalid syntax
>
> I tried changing socket.error to ConnectionRefusedError. and still got
the same error.
>
> Please tell me if the problem is with Rstudio, Python version or the
syntax.
>
> TIA
> -Shaunak
> --
> https://mail.python.org/mailman/listinfo/python-list

Looks like you are missing a colon after 'as e'...    .... as e:  might do
the trick

Nathan

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 11:58 -0800
  Re: Exception handling for socket.error in Python 3.5/RStudio Nathan Hilterbrand <nhilterbrand@gmail.com> - 2016-02-05 15:07 -0500
    Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 12:11 -0800
      Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 12:17 -0800
  Re: Exception handling for socket.error in Python 3.5/RStudio "Martin A. Brown" <martin@linux-ip.net> - 2016-02-05 12:08 -0800
    Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 12:22 -0800
  Re: Exception handling for socket.error in Python 3.5/RStudio "Martin A. Brown" <martin@linux-ip.net> - 2016-02-05 12:44 -0800
  Re: Exception handling for socket.error in Python 3.5/RStudio "Martin A. Brown" <martin@linux-ip.net> - 2016-02-05 13:01 -0800
  Re: Exception handling for socket.error in Python 3.5/RStudio Chris Angelico <rosuav@gmail.com> - 2016-02-06 08:01 +1100
  Re: Exception handling for socket.error in Python 3.5/RStudio Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-02-05 19:08 -0200
    Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 13:26 -0800
      Re: Exception handling for socket.error in Python 3.5/RStudio Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-02-05 19:37 -0200
  Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 13:57 -0800
  Re: Exception handling for socket.error in Python 3.5/RStudio Chris Angelico <rosuav@gmail.com> - 2016-02-06 08:57 +1100
  Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-05 14:35 -0800
    Re: Exception handling for socket.error in Python 3.5/RStudio Chris Angelico <rosuav@gmail.com> - 2016-02-06 13:04 +1100
  Re: Exception handling for socket.error in Python 3.5/RStudio Shaunak Bangale <shaunak.bangale@gmail.com> - 2016-02-05 13:50 -0700
  Re: Exception handling for socket.error in Python 3.5/RStudio Shaunak Bangale <shaunak.bangale@gmail.com> - 2016-02-05 14:00 -0700
  Re: Exception handling for socket.error in Python 3.5/RStudio Shaunak Bangale <shaunak.bangale@gmail.com> - 2016-02-05 14:15 -0700
  Re: Exception handling for socket.error in Python 3.5/RStudio dieter <dieter@handshake.de> - 2016-02-07 09:23 +0100
    Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-08 00:04 -0800
      Re: Exception handling for socket.error in Python 3.5/RStudio shaunak.bangale@gmail.com - 2016-02-19 10:07 -0800

csiph-web