[Python-Dev] PEP 498 f-string: please remove the special case for spaces
MRAB
python at mrabarnett.plus.com
Tue Aug 11 01:17:04 CEST 2015
More information about the Python-Dev mailing list
Tue Aug 11 01:17:04 CEST 2015
- Previous message (by thread): [Python-Dev] PEP 498 f-string: please remove the special case for spaces
- Next message (by thread): [Python-Dev] [RELEASED] Python 3.5.0rc1 is now available
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2015-08-10 23:54, Victor Stinner wrote: > > PEP 498: > > """ > > > Leading whitespace in expressions is skipped > <https://www.python.org/dev/peps/pep-0498/#id28> > > Because expressions may begin with a left brace ('{'), there is a > problem when parsing such expressions. For example: > >>>> f'{{k:v for k, v in [(1, 2), (3, 4)]}}' '{k:v for k, v in [(1, 2), (3, 4)]}' > > """ > > For me, this example is crazy. You should not add a special case (ignore > spaces) just to support a corner case. > Is it a special case? Don't we already ignore leading spaces in bracketed expressions? > This example can easily be rewritten using a temporary variable and it > makes the code simpler. > > items={k:v for k, v in [(1, 2), (3, 4)]; f'{items}' > > Seriously, a dict-comprehension inside a f-string should be considered > as an abuse of the feature. Don't you think so? > True. Or we can wrap it in parentheses. :-)
- Previous message (by thread): [Python-Dev] PEP 498 f-string: please remove the special case for spaces
- Next message (by thread): [Python-Dev] [RELEASED] Python 3.5.0rc1 is now available
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list