Just learned, or relearned, some things in Python I either never knew or had forgotten:

Create a custom list with arbitrary attribute without subclassing:

>>> type('jclist'), (list,), {'black': False})()
>>> l=_
>>> l.black
>>> l.black=True
>>> l.black

I ended up not using that, but thought it was cool. Pretty sure I've subclassed list before for things I could have done with type.

Also, python3 -i program.py arg arg arg drops you into the interactive prompt after running a program, allowing you to examine globals and state.

Back to blog or home page

last updated 2022-04-09 17:08:46. served from tektonic.jcomeau.com