(May-06-2019, 12:04 AM)Gribouillis Wrote: Why not if hasattr(x, 'radix'):...
?
better way to code it; same idea. i guess this technique risks a user-defined object that has attribute 'radix' for whatever reason.
(May-06-2019, 04:39 AM)buran Wrote: IMHO, importing it is much better than writing some weird test for type. Then depending on how different the function should be you can use @functools.singledispatch(yet another import)
i think that would either end up with a lot of extra code, or a more twisty maze of function calls i would have to figure out to avoid the duplication. it's just a difference in how i shift the decimal point around when there is a whole value there during conversion to string. about 80 lines of code does the same thing for (int,float,Decimal). it's complex when .imag is non-zero and Fraction that will be my future mess.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.