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


Groups > comp.lang.python > #42458

Re: How to do this?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.105
X-Spam-Level *
X-Spam-Evidence '*H*': 0.79; '*S*': 0.00; '[0]': 0.09; 'val': 0.09; 'subject:How': 0.10; 'res': 0.16; 'index': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'header:User-Agent:1': 0.23; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'am,': 0.29; '(like': 0.30; 'code': 0.31; 'index,': 0.31; 'probably': 0.32; 'know.': 0.32; 'maybe': 0.34; "i'd": 0.34; 'but': 0.35; 'there': 0.35; 'fun,': 0.36; 'next': 0.36; 'subject:?': 0.36; 'two': 0.37; 'list': 0.37; 'to:addr:python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; "you're": 0.61; "you've": 0.63; 'received:74.208': 0.68; 'million': 0.74; 'subject:this': 0.83; 'ana': 0.84; 'received:74.208.4.194': 0.84
Date Mon, 01 Apr 2013 07:53:44 -0400
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4
MIME-Version 1.0
To python-list@python.org
Subject Re: How to do this?
References <83a54022-576d-465b-b6bd-7e21cde59d99@googlegroups.com> <mailman.4051.1364813918.2939.python-list@python.org> <29fa109e-8ed0-4b1b-a9c0-473e2bace687@googlegroups.com>
In-Reply-To <29fa109e-8ed0-4b1b-a9c0-473e2bace687@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 8bit
X-Provags-ID V02:K0:K40zo76vYNXOCdO0i6K9QavQl8RLNTIMjvTGX5pg0Hp xBEG4UK8BAk+mFiUQW4JeCX3LD0puHX8vTMbhDJ8jpc9FALJzF cXalpVcXMQ7AwP02IZhQlVr+SNBcFUNTbZ/sW3uxsYtyxYrnpO 6yxLLuz5fdO6wmatpFbhtsTJkqrfx7N0aCzxq39cSxhyCIJZhA CY5swI0uFhir35+Twlcnj54OS0ldL/KEDVf6omWj0wY2ai49R+ gowmK/WFE/evR4XKqL18PND67Pe9hYmGSs1/FEd66G0bx7v7uG VD0E4+cJ6TK096FCV+XDw4iZYUoGt2HkNRE0s8bCMndF11oXw= =
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.4054.1364817250.2939.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364817250 news.xs4all.nl 6882 [2001:888:2000:d::a6]:57256
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42458

Show key headers only | View raw


On 04/01/2013 07:08 AM, Ana Dionísio wrote:
> [0 0 0 0 0.17 0.17 0.17 0.17 0 0 0 0.17 0.17 0.17 0 0 0 0 0 0 0]


I'd do
res = "[0 0 0 0 0.17 0.17 0.17 0.17 0 0 0 0.17 0.17 0.17 0 0 0 0 0 0 0]"

Unless there's a pattern you're trying to accomplish (like maybe next 
time you want to do "it" for a list of two million items), there's 
little point in writing code to do what you've already predetermined. 
And if there is a pattern, you'd probably better let us know.

But if it's for fun,



vt = [0] * 21
for index, val in enumerate(vt):
     if 3<index<8 or 10<index<14:
         vt[index] = 0.17


or


vt = [0] * 21
for index, val in enumerate(vt):
     if index in (4,5,6,7,11,12,13):
         vt[index] = 0.17


-- 
-- 
DaveA

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


Thread

How to do this? Ana Dionísio <anadionisio257@gmail.com> - 2013-04-01 03:14 -0700
  Re: How to do this? Vincent Vande Vyvre <vincent.vandevyvre@swing.be> - 2013-04-01 12:58 +0200
    Re: How to do this? Ana Dionísio <anadionisio257@gmail.com> - 2013-04-01 04:08 -0700
      Re: How to do this? Peter Otten <__peter__@web.de> - 2013-04-01 13:32 +0200
      Re: How to do this? Dave Angel <davea@davea.name> - 2013-04-01 07:53 -0400
    Re: How to do this? Ana Dionísio <anadionisio257@gmail.com> - 2013-04-01 04:08 -0700
  Re: How to do this? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-04-01 13:28 +0100

csiph-web