Paul McGuire
mastodon 4.7.3he/him - Author/maintainer of #pyparsing, #littletable, #plusminus - I do digital art when I get the time. Co-author of "Python in a Nutshell, 4th Ed". PSF Fellow. Avatar: NAT #python #pynutshell4
Here are some emojidentifiers for your next Python code:
import math
乁_ツ_ㄏ = None
乁_益_ㄏ = math.nan
ఠ_ఠ = isinstance
def minnums(values: list | 乁_ツ_ㄏ = 乁_ツ_ㄏ):
if (
values is 乁_ツ_ㄏ
or not all(ఠ_ఠ(n, (float, int))
for n in values)
):
return 乁_益_ㄏ
return min(values)
And these simplifications to type hints:
- typing simplifications
- List, Dict, Tuple, etc. -> list, dict, and tuple (3.9)
- Union[X, Y] and Optional[X] -> X|Y and X|None (3.10)
- no more class Z(Generic[T]), just class Z[T] (3.12)
- also def last[T](seq: Sequence[T]) -> T (3.12)
- 'type' as a statement (3.12)
@zauberlaus@chaos.social It is one of a few stdlib modules that have added command-line functionality, along with uuid, random, sqlite3, etc. json is a little different because it previously released the json.tool command-line function, but now in 3.14 it is exposed as just json, so python -m json - a Python version of jq.
@tartley@fosstodon.org Thanks for posting the article. asyncio has been off my radar for a while, but I'm delving into it more and more these days. Another recent addition is asyncio.to_thread(). It's a nice way to async-ify a synchronous call, though its really just a convenience form of asyncio.run_in_executor(). I've looked at TaskGroup a little, but I'll revisit after I read your article in a little more depth.
@catsalad@infosec.exchange It's not 1 but 2 characters: _· This is a legal variable name in Python. The second character is the Unicode MIDDLE DOT. It is only legal as a body character, not an initial character, so you need the leading "_".