Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20502
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.013 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'subject:module': 0.04; 'subject:Python': 0.05; 'subject:code': 0.07; 'ah,': 0.09; 'received:mail-lpp01m010-f46.google.com': 0.09; 'skip:l 60': 0.09; 'def': 0.13; 'result,': 0.15; 'iterator': 0.16; 'subject:Mac': 0.16; 'tempted': 0.16; 'this:': 0.16; 'wed,': 0.17; 'wrote:': 0.18; 'cheers,': 0.20; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; 'cache': 0.24; 'suggestion': 0.26; 'message-id:@mail.gmail.com': 0.29; 'yield': 0.29; 'correct': 0.29; 'pm,': 0.29; 'received:209.85.215.46': 0.32; 'list': 0.32; 'there': 0.33; 'to:addr:python-list': 0.35; 'none': 0.35; 'something': 0.35; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'received:209.85': 0.38; 'somewhat': 0.38; 'some': 0.38; 'doing': 0.38; 'i.e.': 0.39; 'received:209.85.215': 0.39; 'received:209': 0.39; 'might': 0.40; 'to:addr:python.org': 0.40; 'more': 0.61; 'custom': 0.61; 'worth': 0.61; 'simple': 0.61; 'your': 0.61; 'believe': 0.65; 'complexity.': 0.84; 'dealers': 0.84; 'subject:plus': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=LVd2FJPbRv4uOrb3t37yGE52O4jydfxAbYMar0/c1fQ=; b=CgLfyA+McbHgN7Y0tEuktA93jZoO5zQaEY4y9pAuyaQe49xF9QbzqIphHN4EC/W0DE /HVlKdQGPJpr/bK/bk4DgOiMxAXvXVXn++orSas2Z9ry3lMmuuem1YVlp/tYQyNJU8A4 fWEhIsL4o2KYqsea/FX24j5FDKh/i9DdS73iI= |
| MIME-Version | 1.0 |
| In-Reply-To | <jhhl4o$2ar$1@news.albasani.net> |
| References | <jhhfc6$go$1@news.albasani.net> <mailman.5868.1329350900.27778.python-list@python.org> <jhhl4o$2ar$1@news.albasani.net> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Wed, 15 Feb 2012 22:03:44 -0700 |
| Subject | Re: Wanted: Criticism of code for a Python module, plus a Mac tester |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| 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.5876.1329368656.27778.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1329368656 news.xs4all.nl 6935 [2001:888:2000:d::a6]:53141 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:20502 |
Show key headers only | View raw
On Wed, Feb 15, 2012 at 6:11 PM, HoneyMonster <someone@someplace.invalid> wrote:
> As to your first suggestion though, I am having some difficulty. Note
> that the vulnerability rotates; i.e. CONDITIONS[4] is not the same as
> CONDITIONS[0].
> Is there a better way of doing it than a simple list.append()?
Ah, it's more complicated than I realized. I believe this generates
the correct result, although adding None to the dealers list is
somewhat unsatisfactory:
DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West", None]
VULNERABILITIES = [
"Neither vulnerable", "North-South vulnerable",
"East-West vulnerable", "Both vulnerable",
]
CONDITIONS = [(d, v) for (d, v) in zip(DEALERS * 4, VULNERABILITIES * 5) if d]
I might be tempted to write a custom iterator for it, something like this:
def rotating(iterable):
cache = collections.deque()
for value in iterable:
yield value
cache.append(value)
while True:
cache.rotate(-1)
for value in cache:
yield value
# Using the original 4-length DEALERS list
CONDITIONS = list(itertools.islice(itertools.izip(itertools.cycle(DEALERS),
rotating(VULNERABILITIES)), 16))
But I don't know that it's really worth the added complexity.
Cheers,
Ian
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Wanted: Criticism of code for a Python module, plus a Mac tester HoneyMonster <someone@someplace.invalid> - 2012-02-15 23:33 +0000
Re: Wanted: Criticism of code for a Python module, plus a Mac tester Ian Kelly <ian.g.kelly@gmail.com> - 2012-02-15 17:07 -0700
Re: Wanted: Criticism of code for a Python module, plus a Mac tester HoneyMonster <someone@someplace.invalid> - 2012-02-16 01:11 +0000
Re: Wanted: Criticism of code for a Python module, plus a Mac tester Ian Kelly <ian.g.kelly@gmail.com> - 2012-02-15 22:03 -0700
Re: Wanted: Criticism of code for a Python module, plus a Mac tester Arnaud Delobelle <arnodel@gmail.com> - 2012-02-16 07:59 +0000
Re: Wanted: Criticism of code for a Python module, plus a Mac tester Tim Chase <python.list@tim.thechases.com> - 2012-02-15 18:43 -0600
csiph-web