是的,您需要重写
__new__特殊方法:
class MySet(frozenset): def __new__(cls, *args): if args and isinstance (args[0], basestring): args = (args[0].split (),) + args[1:] return super (MySet, cls).__new__(cls, *args)print MySet ('foo bar baz')输出为:
MySet(['baz', 'foo', 'bar'])



