What is the best way to imitate types in Python?
How this TestResult Haskell datatype could be defined in Python?
data TestResult
= TestResult {name :: String,
feature :: String,
passed :: Bool,
errorMessage :: String}
I tried that, but it looks kinda silly. Are there another ways to approach that behavior?
class TestResult:
def __init__(self, name, feature, passed, errorMessage):
self.name = name
self.feature = feature
self.passed = passed
self.errorMessage = errorMessage
I’m not looking for some type-superfluity, but for something like “type constructor” magic kludge to combine some data stubs in a logically single thing.
For immutable data you can use
collections.namedtuple: