| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
They are alternate constructors which only accept numbers (including objects with special methods __float__, __complex__ and __index__), but not strings.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
|
@serhiy-storchaka Are you still interested in pursuing this? Looks like it's still a draft; what's needed to make it ready for review? |
Sorry, something went wrong.
|
It needs documentation. I'll write it if the rest be set. It differs from your original idea (class methods instead of operator functions), so I do not know what you think about this. The spelling is also can be discussed (from_number vs fromnumber, or maybe something other?) Should int.from_number be added? Should we add also special constructors for parsing? int.parse or int.from_string, etc. It can be done in a different PR, but it is useful to keep it in mind. |
Sorry, something went wrong.
|
@serhiy-storchaka, some tests refactoring in test_float/complex is irrelevant for this pr. Can I port this as a separate pr? |
Sorry, something went wrong.
|
This tests refactoring in test_float/complex is required for testing from_number() methods. Without it they are irrelevant. Why do you need this? |
Sorry, something went wrong.
I was thinking about similar refactoring while improving test coverage for the complexobject.c. So, maybe this could be useful regardless of the fate of this pr. |
Sorry, something went wrong.
|
@mdickinson I added docs and remove the draft status. Hope it will help with review. |
Sorry, something went wrong.
Taken from python#26827 Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
There was a problem hiding this comment.
This LGTM, and works as expected in my manual testing. I only have a couple of grammar nitpicks.
Thank you!
Sorry, something went wrong.
|
|
||
| .. classmethod:: float.from_number(x) | ||
|
|
||
| Class method to return a floating point number constructed from a number *x*. |
There was a problem hiding this comment.
Super-nitpick: I prefer the spelling floating-point number, with a hyphen (the "floating-point" part acts as a compound adjective). I think that's what we mostly use throughout the docs (though no doubt there are exceptions).
Sorry, something went wrong.
There was a problem hiding this comment.
This descriptions was simply copied from the float constructor description.
"floating-point" occurs 118 time, "floating point" occurs at least 159 times (in several cases it is split between lines, so it is not easy to get accurate number).
So for now I leave "floating point" for consistency with the constructor description. We will solve this in a separate issue.
Sorry, something went wrong.
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
…thonGH-26827) They are alternate constructors which only accept numbers (including objects with special methods __float__, __complex__ and __index__), but not strings.
| Back | FazBrowse Home | New Git URL |
They are alternate constructors which only accept numbers
(including objects with special methods __float__, __complex__
and __index__), but not strings.
https://bugs.python.org/issue40801