I have the following class:
class MySet(set): def __init__(self, arg=None): if isinstance(arg, basestring): arg = arg.split() set.__init__(self, arg)
This works as expected (initializing a set with the words of a string, not letters). However, when I want to do the same with an immutable version of the set, the __init__ method seems to be ignored:
class MySet(frozenset): def __init__(self, arg=None): if isinstance(arg, basestring): arg = arg.split() frozenset.__init__(self, arg)
Is it possible to achieve something like this with __new__ ?
source share