Comments on: Changement dans l’unpacking des iterables en Python 3 http://sametmax.com/changement-dans-lunpacking-des-iterables-en-python-3/ Deux développeurs en vadrouille qui se sortent les doigts du code Wed, 05 Feb 2014 12:15:31 +0000 hourly 1 http://wordpress.org/?v=3.3.1 By: A horse with no http://sametmax.com/changement-dans-lunpacking-des-iterables-en-python-3/#comment-17304 A horse with no Fri, 20 Dec 2013 13:07:05 +0000 http://sametmax.com/?p=7656#comment-17304 @Recher : si tu as un navigateur sous la main, tu as un python 3 sous la main ;) @Recher : si tu as un navigateur sous la main, tu as un python 3 sous la main ;)

]]>
By: residante http://sametmax.com/changement-dans-lunpacking-des-iterables-en-python-3/#comment-17296 residante Fri, 20 Dec 2013 10:01:41 +0000 http://sametmax.com/?p=7656#comment-17296 Liste vide apparemment ce qui n'est pas plus mal. <pre lang="python"> >>> liste = [0, 1, 2] >>> a, b, c, *d = liste >>> a, b, c, d (0, 1, 2, []) </pre> Liste vide apparemment ce qui n’est pas plus mal.

&gt;&gt;&gt; liste = [0, 1, 2]
&gt;&gt;&gt; a, b, c, *d = liste
&gt;&gt;&gt; a, b, c, d
(0, 1, 2, [])
]]>
By: Recher http://sametmax.com/changement-dans-lunpacking-des-iterables-en-python-3/#comment-17293 Recher Fri, 20 Dec 2013 09:46:10 +0000 http://sametmax.com/?p=7656#comment-17293 Ça donnerait quoi ça ? <pre lang="python">liste = [0, 1, 2] a, b, c, *d = liste </pre> Ça fait une exception, ou ça met une liste vide dans d ? (j'ai pas de python 3 sous la main pour le tester) Ça donnerait quoi ça ?

liste = [0, 1, 2]
a, b, c, *d = liste

Ça fait une exception, ou ça met une liste vide dans d ?

(j’ai pas de python 3 sous la main pour le tester)

]]>
By: Sam http://sametmax.com/changement-dans-lunpacking-des-iterables-en-python-3/#comment-17292 Sam Fri, 20 Dec 2013 09:45:52 +0000 http://sametmax.com/?p=7656#comment-17292 @foxmask : en 2.7, on pouvait faire : <pre lang="python"> a, b = l[0], l[1:]</pre> Mais ça ne marque qu'avec les sliceable, donc pas avec tous les itérables comme les générateurs. @foxmask : en 2.7, on pouvait faire :

a, b = l[0], l[1:]

Mais ça ne marque qu’avec les sliceable, donc pas avec tous les itérables comme les générateurs.

]]>
By: policier moustachu http://sametmax.com/changement-dans-lunpacking-des-iterables-en-python-3/#comment-17290 policier moustachu Fri, 20 Dec 2013 09:24:36 +0000 http://sametmax.com/?p=7656#comment-17290 yeah yeah

]]>
By: foxmask http://sametmax.com/changement-dans-lunpacking-des-iterables-en-python-3/#comment-17283 foxmask Fri, 20 Dec 2013 08:41:51 +0000 http://sametmax.com/?p=7656#comment-17283 on ne peut pas faire cela en python 2.x ? bon je me réponds zamoimeme j'ai fait le test tout connement : nan on peut pas : sinon ca donne <code>In [4]: a, *b = l File "", line 1 a, *b = l ^ SyntaxError: invalid syntax </code> on ne peut pas faire cela en python 2.x ?

bon je me réponds zamoimeme j’ai fait le test tout connement : nan on peut pas : sinon ca donne

In [4]: a, *b = l
File "", line 1
a, *b = l
^
SyntaxError: invalid syntax

]]>