dimanche 17 juillet 2016

How to get __init__() to raise a more useful exception instead of TypeError when incorrect # of arguments?


I have a class with an init that takes many arguments--some required, some not. If one of the needed arguments is not supplied, you may get a TypeError, with an unhelpful message like 'requires at least 10 arguments (14 given)'. I would like to have a custom TypeError subclass that actually informs the user of which arguments are missing.

Aucun commentaire:

Enregistrer un commentaire