Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20492
| References | <jhhfc6$go$1@news.albasani.net> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2012-02-15 17:07 -0700 |
| Subject | Re: Wanted: Criticism of code for a Python module, plus a Mac tester |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5868.1329350900.27778.python-list@python.org> (permalink) |
On Wed, Feb 15, 2012 at 4:33 PM, HoneyMonster <someone@someplace.invalid> wrote:
> Secondly, as a more general point I would welcome comments on code
> quality, adherence to standards and so forth. The code is at:
Looks pretty nice overall. To reduce repetition, I would have
constructed the CONDITIONS list by iteration like you did the DECK
list, something like:
DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West"]
VULNERABILITIES = [
"Neither vulnerable", "North-South vulnerable",
"East-West vulnerable", "Both vulnerable",
]
CONDITIONS = [(d, v) for d in DEALERS for v in VULNERABILITIES]
You could also eliminate some repetition in the deal method by putting
the suit lists in a local dict:
suits = {'S': self.spades, 'H': self.hearts,
'D': self.diamonds, 'C': self.clubs}
for card in cards:
suits[DECK[card][SUIT]].append(DECK[card][RANK])
Another comment I had at first was that instead of creating the pack
list, which is just a list of indexes into DECK, you could shuffle and
deal the DECK list directly. But then I realized that the indirection
allows you to easily sort the cards in the desired order, so that
should be left alone.
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