Re: [Tutor] output is all integer when there should be some floats

2015-04-26 Thread Jim Mooney Py3winXP
On 26 April 2015 at 04:02, Steven D'Aprano wrote: > for kind in (int, float): > try: > return kind(astring) > That puzzled me for a moment until I remembered you can toss functions around in Python. Something to play with on a Sunday afternoon ;') But aren't most langua

Re: [Tutor] output is all integer when there should be some floats

2015-04-26 Thread Steven D'Aprano
On Sat, Apr 25, 2015 at 09:18:53PM -0700, Jim Mooney Py3winXP wrote: > It seems odd to me that there are three tests to see if user input is > digits - isdecimal, isdigit, isnumeric, but nothing to test for a float > unless you use a try - except. Or did I miss something? Yes -- the string tests d

[Tutor] output is all integer when there should be some floats

2015-04-26 Thread Jim Mooney Py3winXP
It seems odd to me that there are three tests to see if user input is digits - isdecimal, isdigit, isnumeric, but nothing to test for a float unless you use a try - except. Or did I miss something? Anyway, I tried a try - except, but I don't see why my output is all integer when I only convert to i