Gmail eats Python

Seb spluque at gmail.com
Sun Jul 26 17:36:58 EDT 2015


And for those interested in how I received Laura's message (the one I
replied to):

---<--------------------cut here---------------start------------------->---
Path: news.gmane.org!not-for-mail
From: Laura Creighton <lac at openend.se>
Newsgroups: gmane.comp.python.general
Subject: Re: scalar vs array and program control
Date: Sat, 25 Jul 2015 14:44:43 +0200
Lines: 44
Approved: news at gmane.org
Message-ID: <201507251244.t6PCihmd023479 at fido.openend.se>
References: <87vbd850qa.fsf at gmail.com><201507251101.t6PB1LqE021165 at fido.openend.se>
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: ger.gmane.org 1437828370 13839 80.91.229.3 (25 Jul 2015 12:46:10 GMT)
X-Complaints-To: usenet at ger.gmane.org
NNTP-Posting-Date: Sat, 25 Jul 2015 12:46:10 +0000 (UTC)
Cc: Seb <spluque at gmail.com>
To: python-list at python.org
Original-X-From: python-list-bounces+python-python-list=m.gmane.org at python.org Sat Jul 25 14:46:03 2015
Return-path: <python-list-bounces+python-python-list=m.gmane.org at python.org>
Envelope-to: python-python-list at m.gmane.org
Original-Received: from mail.python.org ([82.94.164.166])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <python-list-bounces+python-python-list=m.gmane.org at python.org>)
	id 1ZIyq2-0002GT-Ta
	for python-python-list at m.gmane.org; Sat, 25 Jul 2015 14:46:03 +0200
Original-Received: from albatross.python.org (localhost [127.0.0.1])
	by mail.python.org (Postfix) with ESMTP id 3mdnFQ2j3LzPgt
	for <python-python-list at m.gmane.org>; Sat, 25 Jul 2015 14:46:02 +0200 (CEST)
X-Original-To: python-list at python.org
Delivered-To: python-list at mail.python.org
Original-Received: from albatross.python.org (localhost [127.0.0.1])
 by mail.python.org (Postfix) with ESMTP id 3mdnD81R8jzPZj
 for <python-list at python.org>; Sat, 25 Jul 2015 14:44:56 +0200 (CEST)
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'revision': 0.05; 'chunk':
 0.07; 'exception.': 0.07; 'smallest': 0.07; 'thats': 0.07;
 'valueerror:': 0.07; 'received:openend.se': 0.09;
 'received:theraft.openend.se': 0.09; 'skip:t 60': 0.09; 'ignore':
 0.14; 'things.': 0.15; '>try:': 0.16; 'from:addr:lac': 0.16;
 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16;
 'happily': 0.16; 'message-id:@fido.openend.se': 0.16;
 'received:89.233': 0.16; 'received:89.233.217': 0.16;
 'received:89.233.217.133': 0.16; 'received:fido': 0.16;
 'received:fido.openend.se': 0.16; 'subject:array': 0.16;
 'subject:program': 0.16; 'try/except': 0.16; 'laura': 0.18;
 'stick': 0.18; 'try:': 0.18; 'cc:2**0': 0.20; 'posted': 0.21;
 'work,': 0.21; 'pass': 0.22; 'errors': 0.23; 'forgot': 0.23;
 'this:': 0.23; 'cc:addr:gmail.com': 0.24; 'written': 0.24; 'header
 :In-Reply-To:1': 0.24; 'skip:m 30': 0.27; 'e 
Original-Received: from localhost (HELO mail.python.org) (127.0.0.1)
 by albatross.python.org with SMTP; 25 Jul 2015 14:44:56 +0200
Original-Received: from theraft.openend.se (theraft.ipv6.openend.se
 [IPv6:2001:16d8:ffca::2])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.python.org (Postfix) with ESMTPS
 for <python-list at python.org>; Sat, 25 Jul 2015 14:44:55 +0200 (CEST)
Original-Received: from fido.openend.se (root at fido.openend.se [89.233.217.133])
 by theraft.openend.se (8.14.4/8.14.4/Debian-4) with ESMTP id t6PCihR6024800
 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL);
 Sat, 25 Jul 2015 14:44:45 +0200
Original-Received: from fido (lac at localhost [127.0.0.1])
 by fido.openend.se (8.14.9/8.14.9/Debian-1) with ESMTP id t6PCihmd023479;
 Sat, 25 Jul 2015 14:44:43 +0200
In-Reply-To: Message from Laura Creighton <lac at openend.se> of "Sat,
 25 Jul 2015 13:01:21 +0200." <201507251101.t6PB1LqE021165 at fido.openend.se>
Content-ID: <23477.1437828283.1 at fido>
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9
 (theraft.openend.se [89.233.217.130]); Sat, 25 Jul 2015 14:44:45 +0200 (CEST)
X-BeenThere: python-list at python.org
X-Mailman-Version: 2.1.20+
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 at python.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list at python.org>
List-Help: <mailto:python-list-request at python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
 <mailto:python-list-request at python.org?subject=subscribe>
Errors-To: python-list-bounces+python-python-list=m.gmane.org at python.org
Original-Sender: "Python-list"
 <python-list-bounces+python-python-list=m.gmane.org at python.org>
Xref: news.gmane.org gmane.comp.python.general:780612
Archived-At: <http://permalink.gmane.org/gmane.comp.python.general/780612>

And because I was rushed and posted without revision I left out something
important.

>So this is, quite likely, the pattern that you are looking for:
>
>try:
>	all_your_code_which_is_happy_with_non_scalars
>except WhateverErrorPythonGivesYouWhenYouTryThisWithScalars:
>       whatever_you_want_to_do_when_this_happens
>
>This is the usual way to do things.

I forgot to tell you that you are supposed to stick the try/except
around the smallest chunk of code that you expect to get the exception.

So you write this as

code_you_expect_always_to_work
more_code_you_expect_always_to_work

try:
	these_four_lines_of_code_that_will_be_unhappy_if_its_a_scalar
except ValueError:	# whatever kind of error the real error is
       whatever_you_want_to_do_when_that_happens

The reason is that if you get any Value Errors in the part of the
code you always expect to work, then you don't want your program
to run happily along running the code for 'its a scalar'.  You don't
want to hide real errors here.

The other thing I forgot to mention is that sometimes you don't want to
do anything but ignore any errors of this sort.

Thats written like this:

code_you_expect_always_to_work
more_code_you_expect_always_to_work

try:
	these_four_lines_of_code_that_will_be_unhappy_if_its_a_scalar
except ValueError:
       pass	    # just ignore it

Laura
---<--------------------cut here---------------end--------------------->---



Cheers,

-- 
Seb




More information about the Python-list mailing list