HEY:
Work in progress so considere this more like a brain dump than battle-tested knowledge (although the ideas do come from the trenches).
Tooling
Re-import modules
The issue: Python caches module imports. Therefor reimporting fixed code actually doesn't change anything.
First solution, interpreter agnostic:
import importlib
importlib.reload(my_module)
Ipython shortcut:
# just run, don't import
%run my_file(.py)
# activate autoreload
%load_ext autoreload
%autoreload 2
More info at the source (including a few caveats).
Data Types
Enums
It basically looks like an immutable data bag.
from enum import auto, unique, Enum
@unique # validate each field is unique
class Ticker(Enum):
idx = auto() # auto seq id
company = 'google'
price = 1023
Ticker['company'] == Ticker.company # True
Ticker('google').name # company
Interesting Links
#coding#python#tips