創屋ぷれす

Python3.9 リリース

10/5にPython3.9がリリースされました。

注目されている機能追加は

str型のremovesuffix()、removeprefix() の追加
if _string.startswith(“preffix”) ? _string[:len(“preffix”)] : _string
みたいなことを書かなくて済みますね。

dict型の|演算子の実装
dictA = dict1.copy()
dictA.update(dict2)

dictA = dict1 | dict2

のように書けるそうです。
1行で書けるってすばらしい!

創屋のホームページはこちらから

Comments are closed.