New submission from mickey695 <[email protected]>:
PEP 3101 states that format strings may only use the "."(getattr) or the "[]"
(getitem) operators to address either attributes or items of parameters.
Should a programmer attempt to, for example, call a function of a parameter as
follows:
>>> d = datetime.datetime(2017, 10, 31)
>>> "{0.ctime()}".format(d)
they will receive an error message such as:
AttributeError: 'datetime.datetime' object has no attribute 'ctime()'
Proposal:
Raise an error stating that cannot embed arbitrary expressions in str.format()
format strings
----------
components: Interpreter Core
messages: 305263
nosy: mickey695
priority: normal
severity: normal
status: open
title: Clarify error message when attempting to call function via str.format()
type: enhancement
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue31907>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com