[issue23275] Can assign [] = (), but not () = []

2016-06-08 Thread Roundup Robot
Roundup Robot added the comment: New changeset 39a72018dd76 by Martin Panter in branch '3.5': Issue #23275: Backport target list assignment documentation fixes https://hg.python.org/cpython/rev/39a72018dd76 New changeset 8700f4d09b28 by Martin Panter in branch '2.7': Issue #23275: Backport

[issue23275] Can assign [] = (), but not () = []

2016-05-18 Thread Martin Panter
Martin Panter added the comment: I just moved the NEWS entry under the alpha 2 heading. For patches I am going to commit myself, I usually write the NEWS beforehand and remember to adjust it when committing. But perhaps I shouldn’t have done that in this case :) --

[issue23275] Can assign [] = (), but not () = []

2016-05-18 Thread Roundup Robot
Roundup Robot added the comment: New changeset d3a75daf61e1 by Martin Panter in branch 'default': Issue #23275: Don’t think this made it into alpha 1 https://hg.python.org/cpython/rev/d3a75daf61e1 -- ___ Python tracker

[issue23275] Can assign [] = (), but not () = []

2016-05-17 Thread Berker Peksag
Berker Peksag added the comment: Thanks Martin. Your edits look much better! :) I will be travelling for PyCon US later this week so I just committed issue23275_v4.diff with minor edits. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed

[issue23275] Can assign [] = (), but not () = []

2016-05-17 Thread Roundup Robot
Roundup Robot added the comment: New changeset 8a0754fed986 by Berker Peksag in branch 'default': Issue #23275: Allow () = iterable assignment syntax https://hg.python.org/cpython/rev/8a0754fed986 -- nosy: +python-dev ___ Python tracker

[issue23275] Can assign [] = (), but not () = []

2016-05-17 Thread Martin Panter
Martin Panter added the comment: Hi Berker. I updated your patch according to my comments in the documentation. I hope you don’t mind. I reverted all the changes about subscripting and slicing an iterable, since this bug is only about assigning to a “target list”. Actually it is true

[issue23275] Can assign [] = (), but not () = []

2016-05-07 Thread Martin Panter
Martin Panter added the comment: Erm, I think you went overboard with the sequence → iterable changes and subscripting; see the review. Also, I think target_list should be made optional in the grammar description. -- ___ Python tracker

[issue23275] Can assign [] = (), but not () = []

2016-05-04 Thread Berker Peksag
Berker Peksag added the comment: Here is an updated patch. I moved the test into test_unpack and added additional tests. sequence -> iterable changes should probably be applied to 3.5 as well. Thanks for the review, Martin. -- type: behavior -> enhancement Added file:

[issue23275] Can assign [] = (), but not () = []

2016-04-26 Thread Martin Panter
Martin Panter added the comment: Okay I’ll let Berker update his patch, but I’m happy to try my hand at updating the documentation if needed. I reviewed the current patch. I can’t say whether the ast.c change is good or not. But IMO the test would be better off in somewhere like

[issue23275] Can assign [] = (), but not () = []

2016-04-26 Thread Berker Peksag
Berker Peksag added the comment: I missed Martin's comment about the documentation. I will update my patch. -- ___ Python tracker ___

[issue23275] Can assign [] = (), but not () = []

2016-04-26 Thread Raymond Hettinger
Raymond Hettinger added the comment: Martin, do you want to take it from here? -- assignee: rhettinger -> martin.panter ___ Python tracker ___

[issue23275] Can assign [] = (), but not () = []

2015-06-13 Thread Berker Peksag
Berker Peksag added the comment: Thanks for the reviews. Here is an updated patch. -- Added file: http://bugs.python.org/file39703/issue23275_v2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23275

[issue23275] Can assign [] = (), but not () = []

2015-05-27 Thread Rahul Gupta
Rahul Gupta added the comment: isn't it logical? [] is a mutable data structure while () is a immutable data structure (b, a) = [1, 2] is fine because a and b are mutable -- nosy: +Rahul Gupta ___ Python tracker rep...@bugs.python.org

[issue23275] Can assign [] = (), but not () = []

2015-05-27 Thread Martin Panter
Martin Panter added the comment: I prefer to unpack into square brackets in general because it is a mnemonic for the star argument being a list: (a, *b) = range(3) a 0 b # A list, even though it was unpacked using tuple-like syntax [1, 2] --

[issue23275] Can assign [] = (), but not () = []

2015-05-27 Thread Devin Jeanpierre
Devin Jeanpierre added the comment: [a, b] = (1, 2) is also fine. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23275 ___ ___ Python-bugs-list

[issue23275] Can assign [] = (), but not () = []

2015-05-27 Thread Ionel Cristian Mărieș
Changes by Ionel Cristian Mărieș cont...@ionelmc.ro: -- nosy: +ionelmc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23275 ___ ___

[issue23275] Can assign [] = (), but not () = []

2015-05-27 Thread Raymond Hettinger
Raymond Hettinger added the comment: Berker's patch looks good. It has several virtues: * the error message is reasonable and clear * it makes the language more consistent * it doesn't break any existing code. * it makes the AST a little simpler and faster by removing a special case The

[issue23275] Can assign [] = (), but not () = []

2015-05-27 Thread flying sheep
flying sheep added the comment: isn't it logical? [] is a mutable data structure while () is a immutable data structure but you don’t assign to data structures, but to names. you *modify* data structures. and in the square bracket assignment syntax you don’t modify the list created by

[issue23275] Can assign [] = (), but not () = []

2015-05-27 Thread Stefan Behnel
Changes by Stefan Behnel sco...@users.sourceforge.net: -- nosy: +scoder ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23275 ___ ___

[issue23275] Can assign [] = (), but not () = []

2015-05-27 Thread Nick Coghlan
Nick Coghlan added the comment: +1 for Martin's suggestion of removing the inconsistency the other way (i.e. allowing () = iterable to mean the same thing as [] = iterable, effectively asserting that an iterable is empty) I also agree with Raymond that it doesn't need to be mentioned in the

[issue23275] Can assign [] = (), but not () = []

2015-04-22 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: About the patch: I'm sure there are other tests to change, in test_syntax.py for example:: It's a syntax error to assign to the empty tuple. Why isn't it an error to assign to the empty list? It will always raise some error at runtime.

[issue23275] Can assign [] = (), but not () = []

2015-04-22 Thread Berker Peksag
Berker Peksag added the comment: I don't have a strong opinion on this, but here is a patch to make () = [] a valid assignment. -- keywords: +patch nosy: +berker.peksag stage: - patch review versions: +Python 3.5 Added file: http://bugs.python.org/file39165/issue23275.diff

[issue23275] Can assign [] = (), but not () = []

2015-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: There is also no reason to break currently working code Agreed. To take one example, David Beazley's PyCon 2015 talk would have been broken by the suggested change! (See https://www.youtube.com/watch?v=MCs5OvhV9S4, at around the 42:17 mark.) If there's

[issue23275] Can assign [] = (), but not () = []

2015-04-19 Thread R. David Murray
R. David Murray added the comment: There is also no reason to break currently working code, which turning this into a syntax error would od. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23275

[issue23275] Can assign [] = (), but not () = []

2015-04-18 Thread Nick Coghlan
Nick Coghlan added the comment: As Raymond notes, this is a fairly harmless quirk - it changes a SyntaxError to an iterable length dependent ValueError: () = [] File stdin, line 1 SyntaxError: can't assign to () [] = () [] = [1] Traceback (most recent call last): File stdin, line 1, in

[issue23275] Can assign [] = (), but not () = []

2015-04-18 Thread Martin Panter
Martin Panter added the comment: I would prefer this be fixed in the opposite direction, to allow “unpacking” an empty iterable using round brackets. I have used this syntax on purpose as a concise way to ensure that a generator is exhaused with no more yields: def gen(): ... yield

[issue23275] Can assign [] = (), but not () = []

2015-03-02 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23275 ___ ___

[issue23275] Can assign [] = (), but not () = []

2015-01-20 Thread Kyle Buzsaki
Kyle Buzsaki added the comment: It seems that assigning to [] is the odd one out in this case. Why is this even possible? [] = () [] = {} [] = set() list() = () File stdin, line 1 SyntaxError: can't assign to function call () = [] File stdin, line 1 SyntaxError: can't assign to () {}

[issue23275] Can assign [] = (), but not () = []

2015-01-20 Thread Martin Panter
Martin Panter added the comment: But () is the odd one out if you consider [a, b] = range(2) [] = range(0) (a, b) = range(2) () = range(0) File stdin, line 1 SyntaxError: can't assign to () -- nosy: +vadmium ___ Python tracker

[issue23275] Can assign [] = (), but not () = []

2015-01-20 Thread eryksun
eryksun added the comment: In ast.c, set_context checks for assignment to an empty tuple, but not an empty list. case List_kind: e-v.List.ctx = ctx; s = e-v.List.elts; break; case Tuple_kind: if (asdl_seq_LEN(e-v.Tuple.elts)) {

[issue23275] Can assign [] = (), but not () = []

2015-01-19 Thread Cesar Kawakami
Changes by Cesar Kawakami cesarkawak...@gmail.com: -- nosy: +Cesar.Kawakami ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23275 ___ ___

[issue23275] Can assign [] = (), but not () = []

2015-01-19 Thread R. David Murray
R. David Murray added the comment: My guess is that it is not worth complicating the parser in order to make these two cases consistent, and it should be treated as a doc error. We'll see what other developers think. -- nosy: +r.david.murray ___

[issue23275] Can assign [] = (), but not () = []

2015-01-19 Thread Devin Jeanpierre
New submission from Devin Jeanpierre: [] = () () = [] File stdin, line 1 SyntaxError: can't assign to () This contradicts the assignment grammar, which would make both illegal: https://docs.python.org/3/reference/simple_stmts.html#assignment-statements -- components: Interpreter

[issue23275] Can assign [] = (), but not () = []

2015-01-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: The starting point is recognizing that this has been around for very long time and is harmless. -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23275