-
-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
This generalises #17.
Currently any class not special-cased by the library must have a constructor that takes a single string.
Even for built-in types this leads to workarounds like the following.
class Time(datetime.time):
def __new__(cls, value: str):
hour, minute = value.split(":")
return super().__new__(cls, int(hour), int(minute))I think supporting transformation functions would add much-needed flexibility.
One possible syntax might be this.
def strptime(value: str):
hour, minute = value.split(":")
return datetime.time(int(hour), int(minute))
reader.map('time').using(strptime) # With or without .to()Metadata
Metadata
Assignees
Labels
No labels