I've been trying to figuring this out for the last few hours, and I'm about to give up.
How do you make sure that in python only a matching specific criteria will create the object?
For example, let's say I want to create an object Hand, and initialize a Hand only when I have enough Fingers in the initializer? (Please just take this as an analogy)
Say,
class Hand:def __init__(self, fingers):# make sure len(fingers)==5, and #only thumb, index, middle, ring, pinky are allowed in fingerspass
Thanks.
These are the closest questions I found, but one is in C++, the other does not answer my question.
checking of constructor parameter
How to overload __init__ method based on argument type?