[issue23677] Mention dict and set comps in library reference

2020-05-10 Thread Furkan Onder


Furkan Onder  added the comment:

PR has been sent.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23677] Mention dict and set comps in library reference

2020-05-10 Thread Furkan Onder


Change by Furkan Onder :


--
nosy: +furkanonder
nosy_count: 8.0 -> 9.0
pull_requests: +19337
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/20027

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23677] Mention dict and set comps in library reference

2019-02-24 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

Assigning to @Mariatta for the CPython mentored sprint.

--
assignee: docs@python -> Mariatta
nosy: +Mariatta, cheryl.sabella
stage: patch review -> needs patch
versions: +Python 3.7, Python 3.8 -Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23677] Mention dict and set comps in library reference

2019-02-24 Thread Mark Lawrence


Change by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23677] Mention dict and set comps in library reference

2016-01-04 Thread Josh Rosenberg

Josh Rosenberg added the comment:

Heck, with the addition of additional unpacking generalizations in 3.5, you can 
make an empty set even without a comprehension: {*()}

Not really recommending the "one-eyed monkey operator", but the addition of 
unpacking generalizations undoes several of the limits on literals that 
previously existed.

--
nosy: +josh.r

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23677] Mention dict and set comps in library reference

2016-01-03 Thread Martin Panter

Martin Panter added the comment:

The distiction about non-empty sets is a bit misleading. You can create an 
empty set via comprehension:

>>> {x for x in ()}
set()

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23677] Mention dict and set comps in library reference

2016-01-03 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti
stage:  -> patch review
type:  -> enhancement
versions: +Python 3.6 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23677] Mention dict and set comps in library reference

2015-03-18 Thread Frank Millman

Frank Millman added the comment:

Lists and tuples are described like this -

class list([iterable]) 
Lists may be constructed in several ways:
[...]

class tuple([iterable]) 
Tuples may be constructed in a number of ways:
[...]

I think a similar approach to Dicts and Sets could make sense -

class dict([**kwarg])
Dicts may be constructed in a number of ways:

- Using a pair of braces to denote the empty dict: {}
- Placing a comma-separated list of key: value pairs within braces: {'jack': 
4098, 'sjoerd': 4127} or {4098: 'jack', 4127: 'sjoerd'}
- Using a dict comprehension: {k: v for k, v in iterable}
- Using the dict() built-in: dict() or dict(**kwarg) or dict(mapping, **kwarg) 
or dict(iterable, **kwarg) 

Add a new example -

f = {k: v for k, v in [('one', 1), ('two', 2), ('three', 3)]}


class set([iterable])
class frozenset([iterable])
Sets may be constructed in a number of ways:

- Non-empty sets (not frozensets) can be created by placing a comma-separated 
list of elements within braces, for example: {'jack', 'sjoerd'}
- Non-empty sets (not frozensets) can be created by using a set comprehension: 
{x for x in iterable}
- Using the set() or frozenset() built-in


The 'bullet-point' construction is not really necessary for Sets, but it would 
make it consistent with the others.


A related point (I can raise a separate Issue if preferred) -

For me, the power of comprehensions lies in their 'filtering' ability. This is 
not mentioned in any of the above examples, so newcomers may wonder why they 
should use them.

We don't want to make the examples too complicated. Maybe just add 'if ...' to 
the example, and provide a cross-reference to Section 6.2.4 in the Language 
Reference (Displays for lists, sets and dictionaries).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23677
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23677] Mention dict and set comps in library reference

2015-03-17 Thread Mark Lawrence

Mark Lawrence added the comment:

That was embarrassing, hopefully this is rather better.

--
nosy: +BreamoreBoy
Added file: http://bugs.python.org/file38534/issue23677_v2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23677
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23677] Mention dict and set comps in library reference

2015-03-16 Thread R. David Murray

R. David Murray added the comment:

Sounds reasonable.  Dict and set comprehensions were added later than list 
comprehensions, and we probably just didn't notice this needed updating.

Mark's patch, however, is incorrect.  Mark: the dict/set literal notation is a 
different thing from a comprehension.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23677
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23677] Mention dict and set comps in library reference

2015-03-16 Thread Mark Lawrence

Changes by Mark Lawrence breamore...@yahoo.co.uk:


--
keywords: +patch
versions: +Python 3.5
Added file: http://bugs.python.org/file38507/issue23677.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23677
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23677] Mention dict and set comps in library reference

2015-03-16 Thread Frank Millman

New submission from Frank Millman:

This is from the documentation at Section 4.6.4. Lists


Lists may be constructed in several ways:

Using a pair of square brackets to denote the empty list: []
Using square brackets, separating items with commas: [a], [a, b, c]
Using a list comprehension: [x for x in iterable]
Using the type constructor: list() or list(iterable)


Comprehensions are mentioned as a constructor.

This is from the documentation at Section 4.10. Mapping Types


Dictionaries can be created by placing a comma-separated list of key: value 
pairs within braces, for example: {'jack': 4098, 'sjoerd': 4127} or {4098: 
'jack', 4127: 'sjoerd'}, or by the dict constructor.

class dict(**kwarg) 
class dict(mapping, **kwarg) 
class dict(iterable, **kwarg) 
Return a new dictionary initialized from an optional positional argument and a 
possibly empty set of keyword arguments.


There is no mention of dictionary comprehensions.

For consistency, I believe that the documentation for Dicts and Sets should 
mention comprehensions.

--
assignee: docs@python
components: Documentation
messages: 238186
nosy: FrankMillman, docs@python
priority: normal
severity: normal
status: open
title: Mention dict and set comps in library reference
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23677
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com