by Phemist · 10y ago · 0 comments
One question, what would be the recommended way to define complex data types? E.g.
def stuff(arg1: int, arg2: dict):
return 'Ok'
where arg2 would be a dictionary that should contain specific, predefined fields? This might also instead be a general question about Python type hintingwe are currently working on a way of doing this which should be released to the development version this week and will be released with version 2.0
basically the modification would allow you to create a new type which has multiple predefined fields. like so:
class User(Type):
username = Chain(text, LongerThan(10))
password = Chain(text, LongerThan(10))
After creating this type you could then use it as a type as normal def stuff(arg1: int, arg2: User):
return 'Ok'I'm begging: please do not reinvent this. Just don't.