You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Explicitly mention bytes and other buffers in the documentation for float() #77748
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2018-05-18.10:41:41.124>labels= ['3.11', 'type-feature', '3.9', '3.10', 'docs']
title='Explicitly mention bytes and other buffers in the documentation for float()'updated_at=<Date2021-12-19.04:18:07.710>user='https://github.com/mjpieters'
float(bytesobject) treats the contents of the bytesobject as a sequence of ASCII characters, and converts those to a float value as if you used float(bytesobject.decode('ASCII')). The same support is extended to other objects implementing the buffer protocol.
The documentation, however, doesn't mention this:
Return a floating point number constructed from a number or string x.
Everywhere else in the functions documentation, "string" refers to an object of type str. Please make it explicit that bytes is also acceptedable, like it does for the int() documentation.
Activity
mjpieters commentedon May 18, 2018
float(bytesobject) treats the contents of the bytesobject as a sequence of ASCII characters, and converts those to a float value as if you used float(bytesobject.decode('ASCII')). The same support is extended to other objects implementing the buffer protocol.
The documentation, however, doesn't mention this:
Everywhere else in the functions documentation, "string" refers to an object of type
str. Please make it explicit thatbytesis also acceptedable, like it does for the int() documentation.