Closed arihantparsoya closed 7 years ago
This was an oversight on my part when providing the first implementation of WC
. Because the __copy__
of Wildcard
actually creates the new copy with an optional
keyword argument and that is covered by the assumptions
, there is no error message. But the optional information was not copied correctly. Renaming the default
paramter to optional
fixes this. If you prefer the other name, you could also override __copy__
.
Here is a corrected version of the WC
class:
class WC(Wildcard, Symbol):
def __init__(self, min_length, fixed_size, variable_name=None, optional=None, **assumptions):
Wildcard.__init__(self, min_length, fixed_size, variable_name, optional)
def __new__(cls, min_length, fixed_size, variable_name=None, optional=None, **assumptions):
cls._sanitize(assumptions, cls)
return WC.__xnew__(cls, min_length, fixed_size, variable_name, optional, **assumptions)
def __getnewargs__(self):
return (self.min_length, self.fixed_size, self.variable_name, self.optional)
@staticmethod
def __xnew__(cls, min_length, fixed_size, variable_name=None, optional=None, **assumptions):
obj = Symbol.__xnew__(cls, variable_name, **assumptions)
return obj
def _hashable_content(self):
return super()._hashable_content() + (self.min_count, self.fixed_size, self.variable_name, self.optional)
Thanks
Output: