The Voidspace Techie Blog

Gravatar I think that's a perfect example of a great mixin style of multiple-inheritance, and I don't see any problems with it. I'll keep an eye on this in case anyone thinks different.


Gravatar What about "def getSpecialValue()" begin your factory for float and str, and "SpecialValue = (float, str)"?

isinstance(v1, SpecialValue) would still work. The drawback would be that you couldn't do isinstance(v1, (SpecialValue, OtherType))

I'm not saying it's a better solution, I'm just giving an alternative.


Gravatar Virgil - the point is that I need to be able to distinguish *between* 'SpecialValue' and other ordinary floats and strings.


Gravatar I had kind of figured that out a few seconds after having submitted my comment. This requirement wasn't clear from your code snippet though. You shouls have added:

v3 = 1.2
assert not isinstance(v3, SpecialValue)


Name:

Email:

URL:

Comment:  ? 


 

Commenting by HaloScan