Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: UNSURE 0.391 X-Spam-Level: *** X-Spam-Evidence: '*H*': 0.51; '*S*': 0.29; 'def': 0.12; 'poker': 0.16; 'pythonic': 0.16; 'subject:More': 0.16; 'lets': 0.24; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'subject:skip:i 10': 0.31; 'another': 0.32; 'received:google.com': 0.35; 'thanks': 0.36; 'hi,': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'highest': 0.39; 'to:addr:python.org': 0.39; 'more': 0.64; 'hand': 0.80; 'rank.': 0.84; 'hand,': 0.93; 'hands': 0.96; 'ranking': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=U3o525GxY1yQkPhzUtSrO89gENFSzFWZT3px0hk/suo=; b=DzfBweDazgyB9i6f5Ycrnt+02hEmrVMqGSumiPbmhGJdr0dbmX9qbBmEJyw7Z4nb0Y +RRxIG3I951Zh8WMicnskwa4caIylyZRwmuYNBBFx1LAwF+H7N/rDuTivWvPq7A4eXmN JiR5G+YiUwisR008mdZiW8R7t2f4xzPekZihHapVK98yc0mKNiMYaOOIk61Y0dH76FQG 5PSOZHNp45DK1/OK4VswEAvH7EqQ+jm9FPCIQWueCUbv436o4vNFTf4BGdn6gvUNsPlP EIqcvfPiy2Wgv3G/DzS/S/RLrR/N6ca7898rLfd5QK2CUDqqovlhF6BTxeOm2j04yyWV vmxQ== MIME-Version: 1.0 X-Received: by 10.182.60.98 with SMTP id g2mr44851841obr.6.1408468159856; Tue, 19 Aug 2014 10:09:19 -0700 (PDT) Date: Tue, 19 Aug 2014 22:39:19 +0530 Subject: More Pythonic implementation From: Shubham Tomar To: python-list@python.org Content-Type: multipart/alternative; boundary=089e0158aaa05887aa0500fe8cc9 X-Mailman-Approved-At: Tue, 19 Aug 2014 20:39:50 +0200 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408473590 news.xs4all.nl 2887 [2001:888:2000:d::a6]:42578 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76595 --089e0158aaa05887aa0500fe8cc9 Content-Type: text/plain; charset=UTF-8 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 --089e0158aaa05887aa0500fe8cc9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,=C2=A0

Lets say I have a function po= ker(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=C2=A0http://www.pokerstars.com/poker/games/rules/hand-rankings/= .

Which of the following is better and more Pythonic ?

def poker(hands):
=C2=A0 =C2=A0 return max= (hands, key=3Dhand_rank)

or=C2=A0

def poker(hands):
=C2=A0 =C2=A0 return max(hand_rank(hands))

Thanks
--089e0158aaa05887aa0500fe8cc9--