>>> isinstance(42, int | str) True >>> isinstance("42", int | str) True >>> isinstance(42.0, int | str) False
https://files.mastodon.social/media_attachments/files/110/014/566/176/837/015/original/9c786b522bd559a0.png
TIL I can use `|` instead of tuples in isinstance() checks since #Python 3.10.
tiflolinux.org - GNU Social is a social network, courtesy of tiflolinux.org. It runs on GNU social, version 2.0.1-beta0, available under the GNU Affero General Public License.
All tiflolinux.org - GNU Social content and data are available under the Creative Commons Attribution 3.0 license.