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


Groups > comp.lang.python > #20504

Re: Wanted: Criticism of code for a Python module, plus a Mac tester

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!feed.xsnews.nl!border-2.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <arnodel@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:module': 0.04; 'subject:Python': 0.05; 'subject:code': 0.07; 'ah,': 0.09; 'received:209.85.214.174': 0.13; 'result,': 0.15; 'listed,': 0.16; 'subject:Mac': 0.16; '\xc2\xa0i': 0.16; 'cc:addr:python-list': 0.16; 'looked': 0.16; 'wed,': 0.17; 'wrote:': 0.18; "haven't": 0.20; '(but': 0.21; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; 'do,': 0.25; 'suggestion': 0.26; 'cc:2**0': 0.26; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.29; 'correct': 0.29; 'pm,': 0.29; 'kelly': 0.30; 'list': 0.32; 'there': 0.33; 'none': 0.35; 'received:209.85.214': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.38; 'somewhat': 0.38; 'could': 0.38; 'some': 0.38; 'doing': 0.38; 'i.e.': 0.39; 'received:209': 0.39; 'more': 0.61; 'simple': 0.61; 'your': 0.61; 'believe': 0.65; 'care': 0.71; '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:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=gs2pKBAulbauI8cSRXWZ1iF2FKxNVWZiLpi1bhOFc24=; b=uEXzZWRv5jhYQp9jfLrbxz9x271AGPYs5JrJFoVOddRxhDMZAyTGE0bFmhDDgMVa0G X37UoAQbNv0Mez56eATNrW79A4/lXdVqpqaluT4KSEazOc8+huYNAxCQshV92ijMmPus 2PVvR5Gp9Ckpa1771mkgUou67Q88vkdW91Spc=
MIME-Version 1.0
In-Reply-To <CALwzidmVESk0cqYfk7+tyXaumKoN3DShfPAwBh4O1t=JHZZyZw@mail.gmail.com>
References <jhhfc6$go$1@news.albasani.net> <mailman.5868.1329350900.27778.python-list@python.org> <jhhl4o$2ar$1@news.albasani.net> <CALwzidmVESk0cqYfk7+tyXaumKoN3DShfPAwBh4O1t=JHZZyZw@mail.gmail.com>
Date Thu, 16 Feb 2012 07:59:50 +0000
Subject Re: Wanted: Criticism of code for a Python module, plus a Mac tester
From Arnaud Delobelle <arnodel@gmail.com>
To Ian Kelly <ian.g.kelly@gmail.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc Python <python-list@python.org>
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.5877.1329379194.27778.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1329379194 news.xs4all.nl 6923 [2001:888:2000:d::a6]:57040
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20504

Show key headers only | View raw


On 16 February 2012 05:03, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> 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]

You could also do:

DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West"]
VULNERABILITIES = [
  "Neither vulnerable", "North-South vulnerable",
  "East-West vulnerable", "Both vulnerable",
]
CONDITIONS = [
    (DEALERS[j], VULNERABILITIES[(i + j)%4])
    for i in range(4) for j in range(4)
]

If you don't care about the order in which the conditions are listed,
you could use

CONDITIONS = itertools.product(DEALERS, VULNERABILITIES)

(But maybe you do, I haven't looked at the code)

-- 
Arnaud

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


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