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

Arnaud Delobelle arnodel at gmail.com
Thu Feb 16 02:59:50 EST 2012

On 16 February 2012 05:03, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Wed, Feb 15, 2012 at 6:11 PM, HoneyMonster <someone at 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
>> 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]
>   "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"]
  "Neither vulnerable", "North-South vulnerable",
  "East-West vulnerable", "Both vulnerable",
    (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


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


More information about the Python-list mailing list