Trey Hunner 🐍 on Nostr: I think I just found my least favorite way to accurately check whether a string ...
I think I just found my least favorite way to accurately check whether a string (value) represents a number in #Python. 😬
value.removeprefix("-").replace(".", "", 1).isnumeric()
Published at
2024-12-19 19:21:01 UTCEvent JSON
{
"id": "d39e236f67aaf0cfbd3ec07ef73934bed2b596423ef627ec5645b3a74956f374",
"pubkey": "7e9159fbfd5526415c8d2de2e4c7654e3660883f9ccae720a70fa3c1f3cf1f45",
"created_at": 1734636061,
"kind": 1,
"tags": [
[
"proxy",
"https://mastodon.social/@treyhunner/113681108915074712",
"web"
],
[
"t",
"python"
],
[
"proxy",
"https://mastodon.social/users/treyhunner/statuses/113681108915074712",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://mastodon.social/users/treyhunner/statuses/113681108915074712",
"pink.momostr"
],
[
"-"
]
],
"content": "I think I just found my least favorite way to accurately check whether a string (value) represents a number in #Python. 😬 \n\nvalue.removeprefix(\"-\").replace(\".\", \"\", 1).isnumeric()",
"sig": "cfb7e4891349b8c5bfb6a31c4a16f92b09095a20cf91c9a254475a437958924976a3bf3059de93c3f48a9214849c524f7940510c1f0c4b64c225201578511364"
}