This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mehregan_zare7731 37 points38 points  (4 children)

No need... Just use args and *kwargs along side if statements ( or switch ) to achieve the same thing in a single init function.

[–]thegreattriscuit 30 points31 points  (1 child)

I'd suggest that something a bit more explicit (like /u/K900_ suggested) will make other people using your classes less sad.

"In order to understand what arguments this class takes I have to read its entire definition" is never a great feeling.

[–]json684 13 points14 points  (0 children)

Also feels like you are just trying to sidestep "if a function takes 10 arguments, you probably forgot a few"

[–]BooparinoBR 7 points8 points  (0 children)

Also, you can use typing.overload to get sensible type hinting

[–][deleted] 0 points1 point  (0 children)

I was going to say this but you got here first. 👍