Re: [Python-Dev] For review: PEP 285: Adding a bool type
Damn, you're right. I'll patch doctest to special-case the snot out of those specific strings <wink>. In the meantime,
def ibool(e): return e and 1 or 0 # or "return operator.truth(e)"
will work across all Pythons forever, or back to 1.4 if you use operator.truth to avoid offending yourself <wink>.
Btw given that probably operator.truth() will become a synonym of bool() the "# or" comment does not apply. Tim, should we start to be worried about the problems you have to get those things right or are you just in very-low-concetration mode? regards, Samuele Pedroni.
[Samuele Pedroni]
Btw given that probably operator.truth() will become a synonym of bool() the "# or" comment does not apply.
I don't see anything about changing operator.truth() in Guido's PEP, and would be surprised if I did: it's been the documented purpose of that function to return 0 or 1 since 1996, and there's no apparent reason to change it. If you want a similar function to return True or False instead, well, that's what the new bool() would do, and TOOWTDI.
Tim, should we start to be worried about the problems you have to get those things right or are you just in very-low-concetration mode?
I'm in no-concentration mode, and, yes, you should pray for me before going to sleep, upon waking, before meals, and once for each tooth that gets brushed. I'll let you know whether it helps! Thanks in advance.
[Tim]
I don't see anything about changing operator.truth() in Guido's PEP, and would be surprised if I did: it's been the documented purpose of that function to return 0 or 1 since 1996, and there's no apparent reason to change it. If you want a similar function to return True or False instead, well, that's what the new bool() would do, and TOOWTDI.
Although I see Guido's patch *does* change operator.truth in this way. I don't think it should.
Tim, should we start to be worried about the problems you have to get those things right or are you just in very-low-concetration mode?
I'm in no-concentration mode, and, yes, you should pray for me before going to sleep, upon waking, before meals, and once for each tooth that gets brushed. I'll let you know whether it helps! Thanks in advance.
You're welcome. I'll do each time I pray for me (seems a more reasonable approach <wink>). I know you can care for yourself. Anyway it was not meant in such a personal sense, it was more about how much bot-friendly (and user-friendly in general) reasoning on the consequences of the change is <wink>.
[Tim]
I don't see anything about changing operator.truth() in Guido's PEP, and would be surprised if I did: it's been the documented purpose of that function to return 0 or 1 since 1996, and there's no apparent reason to change it. If you want a similar function to return True or False instead, well, that's what the new bool() would do, and TOOWTDI.
Although I see Guido's patch *does* change operator.truth in this way. I don't think it should.
Two people, different expectations. Probably Guido should reason explicitly about this and document the outcome in the PEP. regards.
I don't see anything about changing operator.truth() in Guido's PEP, and would be surprised if I did: it's been the documented purpose of that function to return 0 or 1 since 1996, and there's no apparent reason to change it. If you want a similar function to return True or False instead, well, that's what the new bool() would do, and TOOWTDI.
The patch I just submitted change the operator module so that all "predicates" are changed from returning 0 or 1 to returning False or True. This includes operator.truth(). IMO, truth() was intended to "normalize" a Boolean result into two values that clearly stand for truth and falsehood; I don't see a problem with the change. --Guido van Rossum (home page: http://www.python.org/~guido/)
From: Samuele Pedroni
Damn, you're right. I'll patch doctest to special-case the snot out of those specific strings <wink>. In the meantime,
def ibool(e): return e and 1 or 0 # or "return operator.truth(e)"
will work across all Pythons forever, or back to 1.4 if you use operator.truth to avoid offending yourself <wink>.
Btw given that probably operator.truth() will become a synonym of bool() the "# or" comment does not apply.
Btw, as far as I understand ibool can be spelled just as +
+(1>0) 1
regards, Samuele Pedroni.
From: Samuele Pedroni
From: Samuele Pedroni
Damn, you're right. I'll patch doctest to special-case the snot out of those specific strings <wink>. In the meantime,
def ibool(e): return e and 1 or 0 # or "return operator.truth(e)"
will work across all Pythons forever, or back to 1.4 if you use operator.truth to avoid offending yourself <wink>.
Btw given that probably operator.truth() will become a synonym of bool() the "# or" comment does not apply.
Btw, as far as I understand ibool can be spelled just as +
+(1>0) 1
For the specific usage, I mean. Obviously ibool is more general. regards.
participants (3)
-
Guido van Rossum
-
Samuele Pedroni
-
Tim Peters