Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
number plus suffix
#1
i want to convert a number that has a suffix following the digits. i think i will need to split it at the point where the digits end and the suffix begins. the tool to convert ints in C (strtol) can also yield a pointer to where the digits end. int() in Python does not do that and will even fail the conversion if any non-digits follow the digits. i want to convert strings like '5m' and extract the suffix to work with that. 'm' can mean minutes, and with a map having 'm':60 multiply the 5 to get 300. i'd like to also support other bases like int(digits,0) does, as long as the suffix characters are not the same as any digits in that base (like not using 'd' as a suffix for hexadecimal). any suggestions? this is one of the things i need to limit to what is in the Python library itself.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
number plus suffix - by Skaperen - Jun-03-2019, 04:32 AM
RE: number plus suffix - by Gribouillis - Jun-03-2019, 05:41 AM
RE: number plus suffix - by perfringo - Jun-03-2019, 05:59 AM
RE: number plus suffix - by Skaperen - Jun-03-2019, 06:55 PM
RE: number plus suffix - by Gribouillis - Jun-05-2019, 06:11 AM
RE: number plus suffix - by Skaperen - Jun-05-2019, 07:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  add the suffix to the next line Paulman 2 1,442 Dec-05-2021, 10:48 AM
Last Post: Paulman
  String add prefix & suffix nahom 3 3,198 Sep-30-2019, 11:09 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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