Skip to content

Instantly share code, notes, and snippets.

@Cjkjvfnby
Created November 10, 2022 10:22
Show Gist options
  • Save Cjkjvfnby/019311bb75e0fd4cc82614347e07398b to your computer and use it in GitHub Desktop.
Save Cjkjvfnby/019311bb75e0fd4cc82614347e07398b to your computer and use it in GitHub Desktop.
Hello world in Python.
def function():
return "Hello"
class FunctionMeta(type):
def __new__(cls, typename, bases, ns):
return lambda: "world"
Parent = type.__new__(FunctionMeta, "function", (), {})
function.__mro_entries__ = lambda bases: (Parent,)
class Foo(function): # <- WAT?
pass
print(function(), end=" ")
print(Foo())
# See typing.NamedTuple for real-life example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment