On Thu, Jan 29, 2009 at 5:32 AM, spir <denis.s...@free.fr> wrote: > I'm aware that "not 1" is not the same as "~1" in python. And I agree with > that, while I disagree on how it is different. As I see it, both operators > have a close meaning, so that using the same sign (and the same underlying > method name, e.g. __not__) should be allright. This is a common practice in > python and many languages that support OOP. > The flaw here in python is to treat integers as logical values, like if they > were bools. This is for me a conceptual error. So that: > > * If 'not' is only a plain logical operator, then "not 1" must raise > TypeError. > * On the hand hand, "extended logic", meaning apply logic operators to > non-logic values (e.g. "if not s" instead of "if s==''" or "isEmpty(s)"), is > seen by many as a useful feature. > * If 'not' (or '!', or '~') has an extended meaning, and integers are > additionally considered as byte sequences, then it is sensible to give "not > 1" a semantics of bitwise not. So we don't need both "not 1" and "~1".
That way lies madness, you would have a situation where both these expressions would be True for any non-zero integer: not(bool(x)) != bool(not(x)) (x or not x) == False Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor