You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2010-01-11.22:36:41.905>created_at=<Date2008-03-17.17:37:33.157>labels= ['interpreter-core', 'type-bug']
title='Backport set and dict comprehensions'updated_at=<Date2012-11-14.09:00:10.725>user='https://github.com/brettcannon'
Here is a patch to backport dict and set comprehensions to the trunk.
The patch preserves the Python 3.x's syntax and semantics of the
feature. Although this makes dict and set comprehensions is inconsistent
with list comprehension, I believe this is reasonable since the backport
aimed to improve the compatibility of Python 2.x with Python 3.x.
The patch also adds support for dict and set comprehensions to the
'compiler' package. However, the support is quirky and use the list
comprehension semantics of Python 2.x. This allowed me to keep the patch
simple and to keep myself sane ;-).
Finally, the patch changes the name of the following syntax nodes:
'gen_expr', 'gen_iter', 'gen_if', and 'testlist_gexp'. I don't know if
we have compatibility requirements for this; so I don't know if this is
an issue.
Great they are backported to 2.7. Dictionary and set comprehensions are not documented in the tutorial of 2.7, though they are in the language reference. Is it OK to add these to the tutorial? I've uploaded a patch.
Activity
brettcannon commentedon Mar 17, 2008
Dict comprehensions need to be backported.
avassalotti commentedon Aug 5, 2009
Here is a patch to backport dict and set comprehensions to the trunk.
The patch preserves the Python 3.x's syntax and semantics of the
feature. Although this makes dict and set comprehensions is inconsistent
with list comprehension, I believe this is reasonable since the backport
aimed to improve the compatibility of Python 2.x with Python 3.x.
The patch also adds support for dict and set comprehensions to the
'compiler' package. However, the support is quirky and use the list
comprehension semantics of Python 2.x. This allowed me to keep the patch
simple and to keep myself sane ;-).
Finally, the patch changes the name of the following syntax nodes:
'gen_expr', 'gen_iter', 'gen_if', and 'testlist_gexp'. I don't know if
we have compatibility requirements for this; so I don't know if this is
an issue.
[-]Backport dict comprehensions[/-][+]Backport set and dict comprehensions[/+]mdickinson commentedon Aug 6, 2009
Alexandre, I can't get this to apply cleanly to my svn trunk checkout
(r74328) (see attached log). Am I doing something stupid?
avassalotti commentedon Aug 6, 2009
You need to apply the set literal patch I posted in bpo-2335 first.
mdickinson commentedon Aug 6, 2009
Ah, that works. Thanks! (I'll pay more attention to the tracker
Dependencies field in future.)
avassalotti commentedon Dec 11, 2009
If there are no objections, I will commit this patch later this week
after issue bpo-2335.
avassalotti commentedon Jan 11, 2010
Committed in r77422.
metal commentedon Aug 4, 2010
How about fixing set.__repr__ ?
fossilet commentedon Nov 14, 2012
Great they are backported to 2.7. Dictionary and set comprehensions are not documented in the tutorial of 2.7, though they are in the language reference. Is it OK to add these to the tutorial? I've uploaded a patch.
ezio-melotti commentedon Nov 14, 2012
Yes, but please create a new issue.
Is it broken?
fossilet commentedon Nov 14, 2012
I think metal means that the different ways set is repr'd in 2.7 and 3.
In 2.7:
In [9]: a = {x for x in 'abracadabra' if x not in 'abc'}
In [10]: repr(a)
Out[10]: "set(['r', 'd'])"
In 3.2:
In [6]: a = {x for x in 'abracadabra' if x not in 'abc'}
In [7]: repr(a)
Out[7]: "{'r', 'd'}"
We were saying not changing __repr__ in bpo-2335.