[New-bugs-announce] [issue23677] Mention dict and set comps in library reference

Frank Millman report at bugs.python.org
Mon Mar 16 09:50:55 CET 2015

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 at python
components: Documentation
messages: 238186
nosy: FrankMillman, docs at python
priority: normal
severity: normal
status: open
title: Mention dict and set comps in library reference
versions: Python 3.4

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list