Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38171
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <laxmikant.general@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'exception': 0.03; 'syntax': 0.03; 'elif': 0.04; 'debug': 0.05; 'socket': 0.05; 'sys': 0.05; 'except:': 0.07; 'try:': 0.07; 'python': 0.09; '"if': 0.09; '0.1': 0.09; 'hostname': 0.09; 'instance.': 0.09; 'instances.': 0.09; 'port))': 0.09; 'sys.argv[0]': 0.09; 'sys.exit(2)': 0.09; 'cc:addr:python-list': 0.10; 'subject:error': 0.11; '>>': 0.16; '1):': 0.16; '2.0:': 0.16; 'delay,': 0.16; 'pdb': 0.16; 'syntax.': 0.16; 'syntaxerror:': 0.16; 'true:': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'feb': 0.19; 'followed': 0.20; 'import': 0.21; 'exceptions': 0.22; 'cc:2**0': 0.23; '>': 0.23; 'statement': 0.23; 'raise': 0.24; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'skip:[ 10': 0.26; 'am,': 0.27; 'skip:# 10': 0.27; 'message- id:@mail.gmail.com': 0.27; 'interface': 0.27; 'this?': 0.28; 'address)': 0.29; 'socket,': 0.29; 'url:mailman': 0.29; 'skip:& 10': 0.29; 'class': 0.29; 'classes': 0.30; 'figure': 0.30; 'url:python': 0.32; 'file': 0.32; 'could': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'another': 0.33; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'server': 0.35; '2.0': 0.35; 'data,': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'except': 0.36; 'url:org': 0.36; 'client': 0.36; 'level': 0.37; 'being': 0.37; 'why': 0.37; 'drop': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'skip:" 10': 0.40; 'url:mail': 0.40; 'think': 0.40; 'your': 0.60; 'address': 0.60; 'skip:u 10': 0.60; 'more': 0.63; 'brown': 0.65; 'life': 0.66; 'address,': 0.79; '1060': 0.84; '2013': 0.84; 'effectively:': 0.84; 'random,': 0.84; 'thing,': 0.84; 'albert': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=jCJoTORiIsW7/o+GpHS+RcekqCxVSeEpEf7ktMjNCDM=; b=a5FrvEHDmhA5fvvtAmQO9dwsZJEKBcMCgEYkXMRZb+BER6XLXpK35M3grccQDGE0FR eZnyCrutf1pbrRBGlJdmz5RYdcedz+EB/qtXPRIvpC8t1udy0ldmQrtgCs/2MybeR6S4 biKXDjHFPvMefhA93cVBL3afi2aXUvUjoJGk/rPshiq86AQSOwPzQheBmL0WATi9X3DR 6kTJnLjvDNJoQfvXWVJjM7Q5bQKsegoEfygoEEQSc8DRN9XTGtU+Mp/lH05R8I5DfJW0 uSC+skFIai5G1iMqhDF4yNuSo+GGFakWPFUcinZnAknLQP4V3lEY1Kdt4R/q5keiqbUH ysSA== |
| MIME-Version | 1.0 |
| X-Received | by 10.224.193.202 with SMTP id dv10mr1094987qab.77.1360047109113; Mon, 04 Feb 2013 22:51:49 -0800 (PST) |
| In-Reply-To | <1360025881.32270.140661186861365.09CB02A5@webmail.messagingengine.com> |
| References | <CABRP1o-UkR9j3Ry+xYgpFobAo0yETVvy_8pUm4UYZQO0=rSEAw@mail.gmail.com> <1360025881.32270.140661186861365.09CB02A5@webmail.messagingengine.com> |
| Date | Tue, 5 Feb 2013 12:21:49 +0530 |
| Subject | Re: error in except |
| From | Laxmikant Chitare <laxmikant.general@gmail.com> |
| To | Albert Hopkins <marduk@letterboxes.org> |
| Content-Type | multipart/alternative; boundary=20cf300fb4b3d1088004d4f4a420 |
| Cc | 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.1356.1360050582.2939.python-list@python.org> (permalink) |
| Lines | 186 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1360050582 news.xs4all.nl 6884 [2001:888:2000:d::a6]:47187 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:38171 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
One more thing, apart from what Albert mentioned.
Exceptions must be classes or instances. In effect you cannot just do
'raise'. 'raise' statement must be followed by a class or an instance.
On Tue, Feb 5, 2013 at 6:28 AM, Albert Hopkins <marduk@letterboxes.org>wrote:
>
>
> On Mon, Feb 4, 2013, at 04:49 PM, Rodrick Brown wrote:
> > For the life of me I cant figure out why this exception is being thrown.
> > How could I use pdb to debug this?
> >
> > $ python udp_local2.py server
> > File "udp_local2.py", line 36
> > except:
> > ^
> > SyntaxError: invalid syntax
> >
> >
> > #!/usr/bin/env python
> >
> > import random, socket, sys
> > s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
> >
> > MAX = 65535
> > PORT = 1060
> >
> > if 2 <= len(sys.argv) <= 3 and sys.argv[1] == 'server':
> > interface = sys.argv[2] if len(sys.argv) > 2 else ''
> > s.bind((interface, PORT))
> > print 'Listening at', s.getsockname()
> > while True:
> > data, address = s.recvfrom(MAX)
> > if random.randint(0, 1):
> > print 'The client at', address, 'says:', repr(data)
> > s.sendto('Your data was %d bytes' % len(data), address)
> > else:
> > print 'Pretending to drop packet from', address
> >
> > elif len(sys.argv) == 3 and sys.argv[1] == 'client':
> > hostname = sys.argv[2]
> > s.connect((hostname, PORT))
> > print 'Client socket name is', s.getsockname()
> > delay = 0.1
> > while True:
> > s.send('This is another message')
> > print 'Waiting up to', delay, 'seconds for a reply'
> > s.settimeout(delay)
> > try:
> > data = s.recv(MAX)
> > except socket.timeout:
> > delay *= 2
> > if delay > 2.0:
> > raise RuntimeError('I think the server is down')
> > except:
> > raise
> > else:
> > break
> > print 'The server says', repr(data)
> > else:
> > print >> sys.stderr, 'usage: %d server [<interfae>]' %
> > sys.argv[0]
> > print >> sys.stderr, ' or: %d client <host>' % sys.argv[0]
> > sys.exit(2)
> > --
> > http://mail.python.org/mailman/listinfo/python-list
>
> Your "except" statement is on the same level as "if delay > 2.0"..
> effectively:
>
> if delay > 2.0
> ...
> except:
>
> which is not valid syntax. Excepts go with try: blocks, not if: blocks.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: error in except Laxmikant Chitare <laxmikant.general@gmail.com> - 2013-02-05 12:21 +0530
csiph-web