Skip to content

Instantly share code, notes, and snippets.

@autf
Created April 17, 2022 14:51
Show Gist options
  • Save autf/eb1a0d2b6d9291b13881810e84e18163 to your computer and use it in GitHub Desktop.
Save autf/eb1a0d2b6d9291b13881810e84e18163 to your computer and use it in GitHub Desktop.
import dis
import rich # not in std
class Foo:
@staticmethod
def bar(co):
rich.inspect(co)
for c in co.co_consts:
if hasattr(c, 'co_code'):
Foo.bar(c)
co = compile(open(__file__).read(), __file__, 'exec')
Foo.bar(co)
# dis.dis(co)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment