Python Forum

Full Version: Super flexibility in python, examples
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
i did something like that, long ago, but first made a conversion function. this function tried to convert the given argument to int. if that succeeded then it returned the result. if it failed then it tried to convert the given argument to float. if that succeeded then it returned the result. if it failed it finally just returned the original given argument. this allowed input like "1.2" which would be greater than "1". code that uses that will need to understand how to work with different types, correctly, which could make that code be ugly.
Pages: 1 2