contact.tri...@gmail.com wrote:
if (a, b) != (None, None):
or
if a != None != b:
Preference? Pros? Cons? Alternatives?
I couldn't see anyone else give this, but I like
if None not in (a, b):
pass
Jeremy
--
https://mail.python.org/mailman/listinfo/python-list
I couldn't see anyone else give this, but I like
if None not in (a, b):
I did.
I am now considering:
if None not in (a,b):
or
if (a is not None) and (b is not None):
However, I decided to just turn the two parameters into one (sequence), since
they were logically grouped anyhow.
--
On 31/03/14 19:28, Abe wrote:
I couldn't see anyone else give this, but I like
if None not in (a, b):
I did.
I am now considering:
if None not in (a,b):
or
if (a is not None) and (b is not None):
That's just
if not (a is None or b is None):
but you seem to have found your way.
However, I
On Sat, 29 Mar 2014 19:54:09 -0700, Rustom Mody wrote:
On Sunday, March 30, 2014 8:09:45 AM UTC+5:30, Roy Smith wrote:
I have no particular problem with
x 2 y
because it fits the same pattern. But, if you show me
a != None != b:
my brain just goes into overload. Honestly, I
On Sun, Mar 30, 2014 at 4:54 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
On Sun, 30 Mar 2014 13:15:18 +1100, Chris Angelico wrote:
Chained comparisons where you're checking a single variable against two
constants make perfect sense:
2 x 5
Chained comparisons where you
Roy Smith wrote:
But, if you show me
a != None != b:
my brain just goes into overload.
Chained comparisons get weird with not-equal operators.
If you see
a == b == c
then it implies that a == c, but
a != b != c
does *not* imply that a != c. At least it doesn't in
Python; I've never
Chris Angelico ros...@gmail.com writes:
The problem isn't that I can't see what the comparisons are. It makes
very good sense to bound a variable within constants; but you already
know exactly where 2 is on the number line, so asking Is 2 between
these two variables seems a bit odd. Maybe
On Sun, Mar 30, 2014 at 5:52 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
Chris Angelico ros...@gmail.com writes:
The problem isn't that I can't see what the comparisons are. It makes
very good sense to bound a variable within constants; but you already
know exactly where 2 is on the
Gregory Ewing greg.ew...@canterbury.ac.nz:
a != b != c
does *not* imply that a != c. At least it doesn't in Python; I've
never seen any mathematicians write that, so I don't know what they
would make of it.
Any resemblance between mathematics notation and Python is purely
coincidental. I
In article 5337b4e4$0$29994$c3e8da3$54964...@news.astraweb.com,
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
I think Johannes got it right: boolean logic is easier to reason about
when there is a minimum of nots.
I used to do a lot of digital logic design. In certain logic
On 2014-03-30 13:21, Roy Smith wrote:
In article 5337b4e4$0$29994$c3e8da3$54964...@news.astraweb.com,
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
I think Johannes got it right: boolean logic is easier to reason about
when there is a minimum of nots.
I used to do a lot of
Roy Smith wrote:
Adding to the
confusion, many designs would use active low logic, which means a 1
was represented by a low voltage, and a 0 by a high voltage. So, you
quickly end up with gibberish like, not active low clear nand not
active low enable clock.
There are ways of dealing with
On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote:
if (a, b) != (None, None):
or
if a != None != b:
Preference? Pros? Cons? Alternatives?
Do you actually want to check for arbitrary objects which may claim to
equal None, or do you want to check for objects which are None?
Nearly
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes:
if not (a is b is None): ...
Or if you prefer:
if a is not b is not None: ...
1 is not 1 is not None
False
So definitely the former!
ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real:
Do you actually want to check for arbitrary objects which may claim to
equal None, or do you want to check for objects which are None?
Arbitrary objects are not a concern.
if not (a is b is None): ...
if a is not b is not None: ...
Thanks for the examples.
--
On 29.03.2014 20:05, Steven D'Aprano wrote:
On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote:
if (a, b) != (None, None):
or
if a != None != b:
Preference? Pros? Cons? Alternatives?
if not (a is b is None): ...
Or if you prefer:
if a is not b is not None: ...
Is this an
In article lh7cb4$ntu$2...@news.albasani.net,
Johannes Bauer dfnsonfsdu...@gmx.de wrote:
On 29.03.2014 20:05, Steven D'Aprano wrote:
On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote:
if (a, b) != (None, None):
or
if a != None != b:
Preference? Pros? Cons? Alternatives?
Roy Smith r...@panix.com Wrote in message:
In article lh7cb4$ntu$2...@news.albasani.net,
Johannes Bauer dfnsonfsdu...@gmx.de wrote:
On 29.03.2014 20:05, Steven D'Aprano wrote:
On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote:
if (a, b) != (None, None):
or
if a != None !=
On 29.03.2014 22:07, Roy Smith wrote:
I agree with that. But
if (a, b) != (None, None):
seems pretty straight-forward to me too. In fact, if anything, it seems
easier to understand than
if (a is not None) or (b is not None):
Yes, probably. I liked the original, too. If I were
On 29.03.2014 22:55, Johannes Bauer wrote:
if (a is not None) or (b is not None):
Yes, probably. I liked the original, too. If I were writing the code,
I'd probably try to aim to invert the condition though and simply do
if (a is None) and (b is None)
Which is pretty easy to understand
On 2014-03-29 17:07, Roy Smith wrote:
if (a is not None) or (b is not None):
is immediately understandable by everyone?
I agree with that. But
if (a, b) != (None, None):
seems pretty straight-forward to me too. In fact, if anything, it
seems easier to understand than
And
On Mar 29, 2014, at 6:36 PM, Tim Chase wrote:
And for cases where you have more than one or two things to test for
None-itude, you could use
if all(x is None for x in [a, b, c, d]):
do_something_if_theyre_all_None()
I might have written that as:
if set([a, b, c, d]) == set(None)
On 2014-03-29 18:41, Roy Smith wrote:
On Mar 29, 2014, at 6:36 PM, Tim Chase wrote:
And for cases where you have more than one or two things to test
for None-itude, you could use
if all(x is None for x in [a, b, c, d]):
do_something_if_theyre_all_None()
I might have written
In article mailman.8703.1396133206.18130.python-l...@python.org,
Tim Chase t...@thechases.com wrote:
On 2014-03-29 18:41, Roy Smith wrote:
On Mar 29, 2014, at 6:36 PM, Tim Chase wrote:
And for cases where you have more than one or two things to test
for None-itude, you could use
On 3/29/2014 2:56 PM, contact.tri...@gmail.com wrote:
if (a, b) != (None, None):
or
if a != None != b:
Preference? Pros? Cons? Alternatives?
if a is not None is not b
==
if a is not None and None is not b
==
if a is not None and b is not None
which is what I would write if not trying to be
On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase t...@thechases.com wrote:
Though am I correct that your iteration tests for equality, while
mine tests for identity? Also, my version bails early in the event
quitting early is possible. That's particularly useful in the case
of doing something like
Thanks everyone; it has been very educational.
Dave Angel:
...we'll find that two of the alternatives are not even equivalent.
That helped me realize (a,b) != (None, None) is not correct for the function.
It's a case where two parameters have None as the default argument. What I want
is to
On 03/29/2014 02:01 PM, Johannes Bauer wrote:
On 29.03.2014 20:05, Steven D'Aprano wrote:
On Sat, 29 Mar 2014 11:56:50 -0700, contact.trigon wrote:
if (a, b) != (None, None):
or
if a != None != b:
Preference? Pros? Cons? Alternatives?
if not (a is b is None): ...
Or if you prefer:
if a
On 2014-03-30 10:17, Chris Angelico wrote:
On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase t...@thechases.com
wrote:
Though am I correct that your iteration tests for equality, while
mine tests for identity? Also, my version bails early in the
event quitting early is possible. That's
On Sun, Mar 30, 2014 at 12:19 PM, Tim Chase
python.l...@tim.thechases.com wrote:
On 2014-03-30 10:17, Chris Angelico wrote:
On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase t...@thechases.com
wrote:
Though am I correct that your iteration tests for equality, while
mine tests for identity? Also, my
On Sat, 29 Mar 2014 17:07:20 -0400, Roy Smith wrote:
I certainly agree that things like
if a is not b is not None: ...
belong in an obfuscated coding contest.
Apart from the fact that I got it wrong (that's what happens when I post
at 6am after being up all night, thanks for the
On Sun, Mar 30, 2014 at 1:04 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
On Sat, 29 Mar 2014 17:07:20 -0400, Roy Smith wrote:
I certainly agree that things like
if a is not b is not None: ...
belong in an obfuscated coding contest.
Apart from the fact that I got it
On Sat, 29 Mar 2014 17:36:55 -0500, Tim Chase wrote:
And for cases where you have more than one or two things to test for
None-itude, you could use
if all(x is None for x in [a, b, c, d]):
do_something_if_theyre_all_None()
or
if all(x is not None for x in [a, b, c, d]):
In article mailman.8709.1396145720.18130.python-l...@python.org,
Chris Angelico ros...@gmail.com wrote:
Chained comparisons where you're checking a single variable against
two constants make perfect sense:
2 x 5
Chained comparisons where you check a single constant against two
In article 5337807b$0$29994$c3e8da3$54964...@news.astraweb.com,
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
a is b is c is None
And we are all together. See how they run like pigs from a gun, see how
they fly.
--
https://mail.python.org/mailman/listinfo/python-list
On Sunday, March 30, 2014 8:09:45 AM UTC+5:30, Roy Smith wrote:
I have no particular problem with
x 2 y
because it fits the same pattern. But, if you show me
a != None != b:
my brain just goes into overload. Honestly, I don't even know what that
means. My brain keeps trying to
On March 29, 2014 9:43:00 PM CDT, Roy Smith r...@panix.com wrote:
In article 5337807b$0$29994$c3e8da3$54964...@news.astraweb.com,
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
a is b is c is None
And we are all together. See how they run like pigs from a gun, see
how
they
On Sun, 30 Mar 2014 13:15:18 +1100, Chris Angelico wrote:
On Sun, Mar 30, 2014 at 1:04 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
On Sat, 29 Mar 2014 17:07:20 -0400, Roy Smith wrote:
I certainly agree that things like
if a is not b is not None: ...
belong in an
38 matches
Mail list logo