Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76595
| Date | 2014-08-19 22:39 +0530 |
|---|---|
| Subject | More Pythonic implementation |
| From | Shubham Tomar <tomarshubham24@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13161.1408473590.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
Hi,
Lets say I have a function poker(hands) that takes a list of hands and
returns the highest ranking hand, and another function hand_rank(hand) that
takes hand and return its rank. As in Poker
http://www.pokerstars.com/poker/games/rules/hand-rankings/.
Which of the following is better and more Pythonic ?
def poker(hands):
return max(hands, key=hand_rank)
or
def poker(hands):
return max(hand_rank(hands))
Thanks
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
More Pythonic implementation Shubham Tomar <tomarshubham24@gmail.com> - 2014-08-19 22:39 +0530 Re: More Pythonic implementation Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2014-08-20 17:52 +0200
csiph-web