This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author JimmyCarlos
Recipients JimmyCarlos
Date 2021-04-11.14:53:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1618152815.46.0.189413617211.issue43808@roundup.psfhosted.org>
In-reply-to
Content
Hello Python Community!

One feature I think would be helpful would be a method to see if a str can be safely converted into a float. Currently, this is not doable without a long regex or a try-except block, as numbers like "-3.52" contain non-numeric symbols.

My suggestion is to make a new boolean method on the str class. Code-wise, it would behave quite similarly to this code:

def isfloat(s:str) -> bool:
    try:
        float(s)
        return True
    except:
        return False


I appreciate your feedback, so what do you all think?
History
Date User Action Args
2021-04-11 14:53:35JimmyCarlossetrecipients: + JimmyCarlos
2021-04-11 14:53:35JimmyCarlossetmessageid: <1618152815.46.0.189413617211.issue43808@roundup.psfhosted.org>
2021-04-11 14:53:35JimmyCarloslinkissue43808 messages
2021-04-11 14:53:35JimmyCarloscreate