May-06-2021, 12:59 PM
Hi,
Python sys.version_info(major=3, minor=7, micro=9, releaselevel='final', serial=0) on Windows 10 (64)
Thonny 3.3.6
I try to use the isdigit() function to test an input, making sure it is a legal value.
Problem is that for None which will show up often if no value was declared and which certainly is not a digit, it return an error:
AttributeError: 'NoneType' object has no attribute 'isdigit'
From Pythons docs:
"The Python None object, denoting lack of value. This object has no methods. It needs to be treated just like any other object with respect to reference counts."
"Python String isdigit() Method
The isdigit() method returns True if all the characters are digits, otherwise False. Exponents, like ², are also considered to be a digit."
Is this a python issue or my poor understanding?
Python sys.version_info(major=3, minor=7, micro=9, releaselevel='final', serial=0) on Windows 10 (64)
Thonny 3.3.6
I try to use the isdigit() function to test an input, making sure it is a legal value.
if presets.get('last').isdigit() == True : target.set(presets.get('last'))This works OK if the input is a digit or a string.
Problem is that for None which will show up often if no value was declared and which certainly is not a digit, it return an error:
AttributeError: 'NoneType' object has no attribute 'isdigit'
From Pythons docs:
"The Python None object, denoting lack of value. This object has no methods. It needs to be treated just like any other object with respect to reference counts."
"Python String isdigit() Method
The isdigit() method returns True if all the characters are digits, otherwise False. Exponents, like ², are also considered to be a digit."
Is this a python issue or my poor understanding?