Deutsch English Français Italiano |
<67d08c89$0$5196$426a74cc@news.free.fr> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!feeds.phibee-telecom.net!2.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!cleanfeed2-b.proxad.net!nnrp1-1.free.fr!not-for-mail From: Thomas Alexandre <none@no.invalid> Subject: Re: Python does what? Newsgroups: fr.comp.lang.python References: <aB5Wiwv-Cy3MCkoAA9RcNKuT36g@jntp> MIME-Version: 1.0 Organization: =?UTF-8?B?8J+Nv/Cfjbo=?= User-Agent: Pan/0.161 (Chasiv Yar; ) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 11 Mar 2025 19:18:33 GMT Lines: 30 Message-ID: <67d08c89$0$5196$426a74cc@news.free.fr> NNTP-Posting-Date: 11 Mar 2025 20:18:33 CET NNTP-Posting-Host: 78.196.238.42 X-Trace: 1741720713 news-3.free.fr 5196 78.196.238.42:36268 X-Complaints-To: abuse@proxad.net Bytes: 1700 Le Tue, 11 Mar 25 18:47:54 +0000, Python a écrit : >>>> def what(): > .. try: > .. return 12 > .. finally: > .. return 42 .. >>>> what() > ? ? ? > > 1. Essayer de prévoir 42 > 2. Vérifier ``` The return value of a function is determined by the last return statement executed. Since the finally clause always executes, a return statement executed in the finally clause will always be the last one executed ``` https://docs.python.org/3/reference/compound_stmts.html#finally-clause Oui, c'est totalement contre-intuitif - particulièrement dans cet exemple. -- "Ce qu'il faut au fond pour obtenir une espèce de paix avec les hommes, (...) c'est leur permettre en toutes circonstances, de s'étaler, de se vautrer parmi les vantardises niaises. Il n'y a pas de vanité intelligente. C'est un instinct." - Céline