"Andrew Dalke" <[EMAIL PROTECTED]> wrote: > [snipped] > > > Take for example the case where a PhoneNumber class is subclass > > of int. According to LSP, it is perfectly ok to add phone numbers > > together, subtract them, etc, but the result, even if it's a valid > > phone number, just doesn't make sense. > > Mmm, I don't think an integer is a good model of a phone number. > For example, in the US > 00148762040828 > will ring a mobile number in Sweden while > 148762040828 > will give a "this isn't a valid phone number" message.
That's why phone numbers would be a subset of integers, i.e. not every integer would correspond to a valid number, but with the exception of numbers starting with zeros, all valid numbers would be an integers. Regardless, this was not my point; the point was that adding two phone numbers or subtracting them never makes sense semantically. > [snipped] > > > I just noted that conceptually a path is a composite object consisting of > > many properties (dirname, extension, etc.) and its string representation > > is just one of them. Still, I'm not suggesting that a 'pure' solution is > > better that a more practical that covers most usual cases. > > For some reason I think that > > path.dirname() > > is better than > > path.dirname > > Python has properties now so the implementation of the latter is > trivial - put a @property on the line before the "def dirname(self):". Sorry, I used the term 'property' in the broad sense, as the whole exposed API, not the specific python feature; I've no strong preference between path.dirname and path.dirname(). > I think that the string representation of a path is so important that > it *is* the path. There are (at least) two frequently used path string representations, the absolute and the relative to the working directory. Which one *is* the path ? Depending on the application, one of them woud be more natural choice than the other. > I trust my intuition on this, I just don't know how to justify it, or > correct it if I'm wrong. My intuition also happens to support subclassing string, but for practical reasons rather than conceptual. George -- http://mail.python.org/mailman/listinfo/python-list