Jul-09-2020, 10:48 PM
this function gets a str that has decimal digit characters followed by one alphabetic character that indicates how to multiply the number those digits represent. so, the function converts the digits and uses the letter to determine the other number to multiply and returns the product. for example:
i am accustomed to a function in C (strtol,strtoul) that converts until it hits a non-digit and stores a pointer to the non-digit (literally one past the last converted digit). if i need to handle a case where there may be more than 1 character after the digits the Python code above is not enough. is there something good in Python to do that?
in Python, a reference to a string (or anything) can only refer to the whole string (or whole thing), never to a part of it.
timedelta('12m')
-> 720
. what i am looking for is a pythonic way to convert the digits. could it be int(s[:-1])
?i am accustomed to a function in C (strtol,strtoul) that converts until it hits a non-digit and stores a pointer to the non-digit (literally one past the last converted digit). if i need to handle a case where there may be more than 1 character after the digits the Python code above is not enough. is there something good in Python to do that?
in Python, a reference to a string (or anything) can only refer to the whole string (or whole thing), never to a part of it.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.