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.81.170 with SMTP id b10mr8277860pay.31.1351477583382;
        Sun, 28 Oct 2012 19:26:23 -0700 (PDT)
Path: s9ni66465pbb.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!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path: <demianbre...@gmail.com>
X-Original-To: python-l...@python.org
Delivered-To: python-l...@mail.python.org
X-Spam-Status: OK 0.016
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python': 0.09;
	'subject:into': 0.09; 'url:github': 0.09; 'cc:addr:python-list':
	0.10; 'alpha': 0.15; "['a": 0.16; 'subject:array': 0.16; 'wrote:':
	0.17; '>>>': 0.18; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24;
	'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25;
	'question': 0.27; 'received:209.85.210.46': 0.27; 'skip:@ 10':
	0.27; 'subject:list': 0.28; 'received:google.com': 0.34; 'pm,':
	0.35; 'received:192.168.0': 0.35; 'received:209.85': 0.35;
	'something': 0.35; 'message-id:@gmail.com': 0.36; 'charset:us-
	ascii': 0.36; 'turn': 0.36; 'received:209': 0.37; 'subject:: ':
	0.38; 'received:192': 0.39; 'received:192.168': 0.40;
	'header:Received:5': 0.40; 'header:Message-Id:1': 0.62; "'2',":
	0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=content-type:mime-version:subject:from:in-reply-to:date:cc
	:content-transfer-encoding:message-id:references:to:x-mailer;
	bh=P85ndiHpOb62L+4g6TTjoFgNyUexdFsc6xk4Ln+3mT8=;
	b=Zjbh+eREGSdIh6qEtEuvIh2l+v4AmrjWhKMRowSfLwikXRW4oYcHXjymfYVKZaoNiZ
	aPBeXcvZVqDnxTTPjahCipk4leRe9H9gQyG/3idpqEqBDj20q2Bzt+ddacqgSFE487VZ
	nuQf70ild5yj0u0+Ksn3hsfveg1y4KRy/uVVQlccOCZIc/EGV0ppxejcoYUUCut8nHIl
	VWH648ffYKWNXKYuTGqp21bvQZssCd4C9PzyZdL1ezUeF/6Mp/qyFMVGWoxGjAhOlQcG
	8+/HjriTqnQkXyHCJPbSNb1byGm1zDF6MEQ5PDpYzxGeMvwG2DfBAKaS125WNqIxGQWa
	yW4g==
Mime-Version: 1.0 (Mac OS X Mail 6.0 \(1485\))
Subject: Re: turn list of letters into an array of integers
From: Demian Brecht <demianbre...@gmail.com>
In-Reply-To: <07073002-d79f-46f6-83fc-8d20c51b39c3@googlegroups.com>
Date: Tue, 23 Oct 2012 22:45:07 -0700
References: <07073002-d79f-46f6-83fc-8d20c51b39c3@googlegroups.com>
To: seektime <michael.j.kra...@gmail.com>
X-Mailer: Apple Mail (2.1485)
Cc: python-l...@python.org
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.2721.1351057518.27098.python-l...@python.org>
Lines: 22
NNTP-Posting-Host: 2001:888:2000:d::a6
X-Trace: 1351057518 news.xs4all.nl 6850 [2001:888:2000:d::a6]:39784
X-Complaints-To: ab...@xs4all.nl
Bytes: 3670
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

On 2012-10-23, at 10:23 PM, seektime <michael.j.kra...@gmail.com> wrote:
> My question is how can I turn "seq" into a python array?


Something like this perhaps?:

>>> alpha = ('a', 'b')
>>> numeric = ('1', '2')
>>> L = ['a b a\n', 'b b a\n']
>>> s = ' '.join(L)
>>> d = dict(zip(alpha, numeric))
>>> list_ = [d[c] for c in s.strip('\n').split()]
>>> list_
['1', '2', '1', '2', '2', '1']

Demian Brecht
@demianbrecht
http://demianbrecht.github.com