Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python isdigit() and None
#5
Thaks all for your replies and suggestions.
I am aware of several potential solutions. Being new to Python, I just wanted to be sure I'm not doing something wrong.
I also found similar isseus with Int:
Quote:if target.get().isdigit() == False or target.get() == '' or target.get() == None :
AttributeError: 'int' object has no attribute 'isdigit'

And a comment as for the "==True", yes, I know it is not necessary, but I never save on clarity. A program should be as detailed as possible. After many years programming in several languages (new to Python, though), I know how difficult it can be to try to understand a program I made myself some 20 years back. (by the way, the True was not always the obvious default. In the past the '== True' was a must.
And one more related comment:
In good programming, eception handling must not be used as a logic programming item. The best practice is to avoid any exception handling while writing the code, and add it only after the code has been completed and tested. It is intended for the unknown or system errors, not for bugs correction or logic decissions.
In addition, the exception handling, if active while programming and testing, will hide other importand error messages.
Reply


Messages In This Thread
Python isdigit() and None - by samtal - May-06-2021, 12:59 PM
RE: Python isdigit() and None - by perfringo - May-06-2021, 01:40 PM
RE: Python isdigit() and None - by Gribouillis - May-06-2021, 01:50 PM
RE: Python isdigit() and None - by GOTO10 - May-06-2021, 02:04 PM
RE: Python isdigit() and None - by samtal - May-06-2021, 02:54 PM
RE: Python isdigit() and None - by ndc85430 - May-06-2021, 03:06 PM
RE: Python isdigit() and None - by Gribouillis - May-06-2021, 05:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Filter and str.isdigit producing an error tester_V 5 1,963 Aug-12-2022, 07:50 AM
Last Post: Gribouillis
  str.isdigit() vs str.isnumeric() Skaperen 4 6,317 Jun-14-2019, 01:54 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020