Added more words about rejecting binary f-strings.
This commit is contained in:
parent
71c8591e16
commit
86db15618e
16
pep-0498.txt
16
pep-0498.txt
|
@ -459,7 +459,18 @@ combine 'f' with 'b' string literals. The primary problem is that an
|
|||
object's __format__() method may return Unicode data that is not
|
||||
compatible with a bytes string.
|
||||
|
||||
#XXX: maybe allow this, but encode the output as ascii?
|
||||
Binary f-strings would first require a solution for
|
||||
bytes.format(). This idea has been proposed in the past, most recently
|
||||
in PEP 461 [#]_. The discussions of such a feature usually suggest either
|
||||
|
||||
- adding a method such as __bformat__() so an object can control how
|
||||
it is converted to bytes, or
|
||||
|
||||
- having bytes.format() not be as general purpose or extensible as
|
||||
str.format().
|
||||
|
||||
Both of these remain as options in the future, if such functionality
|
||||
is desired.
|
||||
|
||||
!s, !r, and !s are redundant
|
||||
----------------------------
|
||||
|
@ -567,6 +578,9 @@ References
|
|||
.. [#] Differences in str.format() and f-string expressions
|
||||
(https://mail.python.org/pipermail/python-ideas/2015-July/034726.html)
|
||||
|
||||
.. [#] PEP 461 rejects bytes.format(), see section "Proposed variations"
|
||||
(http://legacy.python.org/dev/peps/pep-0461)
|
||||
|
||||
Copyright
|
||||
=========
|
||||
|
||||
|
|
Loading…
Reference in New Issue