Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion turn list of letters into an array of integers

Received: by 10.66.80.4 with SMTP id n4mr1731848pax.7.1351477579155;
        Sun, 28 Oct 2012 19:26:19 -0700 (PDT)
Path: s9ni66462pbb.0!nntp.google.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path: <python-python-l...@m.gmane.org>
X-Original-To: python-l...@python.org
Delivered-To: python-l...@mail.python.org
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:80.91': 0.09;
	'received:80.91.229': 0.09; 'received:gmane.org': 0.09;
	'received:list': 0.09; 'subject:into': 0.09; 'line.split()': 0.16;
	'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16;
	'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16;
	'subject:array': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'split': 0.23;
	'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28;
	'subject:list': 0.28; 'chris': 0.28; 'fighting': 0.29; 'to:addr
	:python-list': 0.33; 'received:org': 0.36; 'subject:: ': 0.38;
	'skip:l 20': 0.38; 'to:addr:python.org': 0.39; 'takes': 0.39;
	'header:Received:5': 0.40; 'idiom': 0.84
X-Injected-Via-Gmane: http://gmane.org/
To: python-l...@python.org
From: Peter Otten <__pete...@web.de>
Subject: Re: turn list of letters into an array of integers
Date: Wed, 24 Oct 2012 09:47:57 +0200
Organization: None
References: <07073002-d79f-46f6-83fc-8d20c51b39c3@googlegroups.com>
	<CAMZYqRR+RMFMy0CiWTDbw_xm1n9EZPxN5HpyoyRSM114xNmGpg@mail.gmail.com>
Mime-Version: 1.0
X-Gmane-NNTP-Posting-Host: p50848f8e.dip.t-dialin.net
User-Agent: KNode/4.7.3
X-BeenThere: python-l...@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-requ...@python.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-l...@python.org>
List-Help: <mailto:python-list-requ...@python.org?subject=help>
List-Subscribe: <http://mail.python.org/mailman/listinfo/python-list>,
	<mailto:python-list-requ...@python.org?subject=subscribe>
Newsgroups: comp.lang.python
Message-ID: <mailman.2739.1351064865.27098.python-l...@python.org>
Lines: 13
NNTP-Posting-Host: 2001:888:2000:d::a6
X-Trace: 1351064865 news.xs4all.nl 6975 [2001:888:2000:d::a6]:40632
X-Complaints-To: ab...@xs4all.nl
Bytes: 2829
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7Bit

Chris Rebert wrote:

> line.strip().split()

No need to strip() if you are going to split on whitespace:

>>> line = " a b c \n"
>>> line.split() == line.strip().split()
True

Lest the new idiom takes on while you are bravely fighting the immortable 
readlines() ;)