Dynamic classes generator in Python