More Pythonic implementation

Shubham Tomar tomarshubham24 at gmail.com
Tue Aug 19 13:09:19 EDT 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140819/b4f36db0/attachment.html>


More information about the Python-list mailing list