Bugs item #1520864, was opened at 2006-07-11 23:21 Message generated for change (Comment added) made by gbrandl You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1520864&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.5 >Status: Open >Resolution: None Priority: 9 Submitted By: Anthony Tuininga (atuining) Assigned to: Neal Norwitz (nnorwitz) Summary: unpack list of singleton tuples not unpacking Initial Comment: The following code works differently in Python 2.5 than Python 2.4: x = [(1,), (2,), (3,)] for y, in x: print y In Python 2.4, this code produces the following: 1 2 3 In Python 2.5, this code produces the following: (1,) (2,) (3,) Interestingly enough the following code: x = (1,) y, = x print y produces the output 1 in both Python 2.4 and Python 2.5. I'm thinking this is not intentional. :-) ---------------------------------------------------------------------- >Comment By: Georg Brandl (gbrandl) Date: 2006-09-04 10:05 Message: Logged In: YES user_id=849994 You're right. Attached patch fixes this. ---------------------------------------------------------------------- Comment By: Sadruddin Rejeb (sadrejeb) Date: 2006-09-04 09:08 Message: Logged In: YES user_id=26911 I have the impression that the bug has only been partially solved, i.e. in 2.5c1, singleton tuples don't get unfoled in list comprehensions. Python 2.5c1 (r25c1:51305, Sep 4 2006, 10:15:09) [GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> l = [(1,), (2,)] >>> print [x for x, in l] [(1,), (2,)] Same example in Python 2.4.3: Python 2.4.3 (#1, Jul 25 2006, 11:53:03) [GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> l = [(1,), (2,)] >>> print [x for x, in l] [1, 2] ---------------------------------------------------------------------- Comment By: Neal Norwitz (nnorwitz) Date: 2006-07-12 05:26 Message: Logged In: YES user_id=33168 Awww come on, can't we change the language just to make your life difficult? ;-) Thanks a lot for catching this! Committed revision 50597. ---------------------------------------------------------------------- Comment By: Raymond Hettinger (rhettinger) Date: 2006-07-12 02:38 Message: Logged In: YES user_id=80475 Ouch. This is bad. The disassembly shows that the compiler isn't generating the unpack_sequence opcode. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1520864&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com