constructor classmethods
David Palao
dpalao.python at gmail.com
Mon Nov 7 06:42:15 EST 2016
>>
>> If the class in question has legitimate, non-testing, reasons to specify different Queues, then make it a default argument instead:
>>
>> def __init__(self, ..., queue=None):
>> if queue is None:
>> queue = Queue()
>> self.queue = queue
>
> I already stated that this is is fine, as long as the number of arguments stays in manageable levels. Although I do think testing is good enough reason to have it injected anytime. For consistency, it makes sense to have same way to create all objects. I wouldn't suggested of using that mechanism in public API's, just in internal components.
>
But if the number of arguments is not manageable, you need to change
the design anyway, for the sake of cleanness. So YAGNI.
More information about the Python-list
mailing list