Skip to content

Instantly share code, notes, and snippets.

@Tarliton
Created October 11, 2020 04:37
Show Gist options
  • Save Tarliton/aece2084ec7b1de0145f34f121aba1e6 to your computer and use it in GitHub Desktop.
Save Tarliton/aece2084ec7b1de0145f34f121aba1e6 to your computer and use it in GitHub Desktop.
namedtuple broken Python 3.9.0

In Python <= 3.8, if you run:

from collections import namedtuple
MyClass = namedtuple("MyClass", "")
m = MyClass()
print(m.__class__['__name__'])
print(type(m.__class__['__name__']))

It will raise TypeError in:

print(m.__class__['__name__'])

In Python 3.9 it prints:

types.GenericAlias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment