today I discovered that
dcc.Input treats the float input 1.0 as the integer 1.
In the documentation there is this warning:
There is a limitation when converting numbers like 1.0 or 0.0, the corresponding number type in callbacks is Integer instead of Float . Please add extra guard casting like
float() within callbacks if needed.
If I want to distinguish the input 1.0 and 1, how would I do it? I have Regex in mind, but wonder if there are any better solutions.
Thanks a bunch!
Just curious, why do you need to distinguish between the two types? What’s your use case?
Float can represents percentage while integer represents the actual fraction.
I do realize that I also could just use two Input components, but that’s a nightmare design-wise.
I would argue it’s not good design to be able to input either fractions or percentage. Just make it clear in the input label which one should be used.
Thanks for the input. I will do just that. Everything else seems to be too complicated.