On Feb 17, 2020, at 04:09, ananthan ananthan <ananthakrishnan15.2001@gmail.com> wrote:
At last found what I was trying to convey.
A new class >>BinaryInt(n: Integer *, bits,signed=False)
It should accept float values.(now >> "bin(5.8)".. will raise an error).
Just float, or any type convertible to int? Whatever you decide, it should be easy to implement. For example, in your __new__ method: # ... # if you only want float, wrap this in an isinstance check intvalue = int(value) # maybe also a try/except/raise around this? if intvalue != value: raise ValueError(f"{cls.__name__} cannot be constructed from non-integral value {value}") self = int.__new__(cls, intvalue) # ... But just throwing out features you want doesn’t help much. You need to do all the work to design everything, and then implement it. There are a dozen questions along the way (including all the ones I‘ve thought of, but probably more that I haven’t), and building the code is the best way to find all of them, and to have enough context to answer each one. Once you have a complete implementation, you can make the case for why this should be in the stdlib. And, if it gets rejected, you still have it for your own use, and can publish it on PyPI for others. (And maybe, if it gets a lot more use than other people expected, you can propose it to be added to the stdlib again in the future.