Python Forum
Determine if string is integer
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Determine if string is integer
#9
I know next to nothing what the 'integer' supposed to be. Test results are not that helpful because there are only pass/fail information and not information what result was expected. Can't help.

Therefore I make just some nitpicking about code:

- it is advisable to use conventions set in PEP8 - Naming Conventions - Function and Variable names

- some things in code can be expressed more concisely:

# instead of:
count = count + 1

# one can use:
count += 1

# instead of:
if ordValue >= 48 and ordValue <= 57

# one can use:
if ord_value in range(48, 58)
if 48 <= ord_value <= 57
- docstring should consist correct information. Currently there is '"""Returns True if testValue is an integer and False otherwise.""". This is not correct, as it considers floats as integers etc. You should not mislead yourself (and others who may read your code) that this function has something to do with Python integers and/or functionality provided by built-in int() function.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Determine if string is integer - by jrodencal - Oct-14-2019, 12:46 AM
RE: Determine if string is integer - by ichabod801 - Oct-14-2019, 01:11 AM
RE: Determine if string is integer - by jrodencal - Oct-14-2019, 01:29 AM
RE: Determine if string is integer - by ichabod801 - Oct-14-2019, 02:11 AM
RE: Determine if string is integer - by perfringo - Oct-14-2019, 02:43 AM
RE: Determine if string is integer - by jrodencal - Oct-14-2019, 03:52 PM
RE: Determine if string is integer - by jrodencal - Oct-14-2019, 05:56 PM
RE: Determine if string is integer - by jefsummers - Oct-14-2019, 06:42 PM
RE: Determine if string is integer - by perfringo - Oct-15-2019, 07:06 AM
RE: Determine if string is integer - by DeaD_EyE - Oct-15-2019, 07:19 AM
RE: Determine if string is integer - by Gribouillis - Oct-15-2019, 07:55 AM
RE: Determine if string is integer - by ichabod801 - Oct-15-2019, 01:21 PM
RE: Determine if string is integer - by jefsummers - Oct-15-2019, 01:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using an integer to manipulate a string/text variable rexyboy2121 1 1,837 Apr-22-2020, 01:37 AM
Last Post: michael1789
  Converting String to Integer Python Johnny1998 5 3,226 Aug-02-2019, 08:13 PM
Last Post: Johnny1998

Forum Jump:

User Panel Messages

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