Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #69337 > unrolled thread
| Started by | contact.trigon@gmail.com |
|---|---|
| First post | 2014-03-29 11:56 -0700 |
| Last post | 2014-03-31 21:22 +0200 |
| Articles | 20 on this page of 39 — 20 participants |
Back to article view | Back to comp.lang.python
checking if two things do not equal None contact.trigon@gmail.com - 2014-03-29 11:56 -0700
Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-29 19:05 +0000
Re: checking if two things do not equal None contact.trigon@gmail.com - 2014-03-29 12:23 -0700
Re: checking if two things do not equal None Lele Gaifax <lele@metapensiero.it> - 2014-03-29 20:24 +0100
Re: checking if two things do not equal None Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-03-29 22:01 +0100
Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 17:07 -0400
Re: checking if two things do not equal None Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-03-29 22:55 +0100
Re: checking if two things do not equal None Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-03-29 23:02 +0100
Re: checking if two things do not equal None Dave Angel <davea@davea.name> - 2014-03-29 18:01 -0400
Re: checking if two things do not equal None contact.trigon@gmail.com - 2014-03-29 16:20 -0700
Re: checking if two things do not equal None Tim Chase <python.list@tim.thechases.com> - 2014-03-29 17:36 -0500
Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-30 02:24 +0000
Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 22:43 -0400
Re: checking if two things do not equal None Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-03-29 22:04 -0500
Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 18:41 -0400
Re: checking if two things do not equal None Tim Chase <tim@thechases.com> - 2014-03-29 17:46 -0500
Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 18:51 -0400
Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 10:17 +1100
Re: checking if two things do not equal None Tim Chase <python.list@tim.thechases.com> - 2014-03-29 20:19 -0500
Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 12:37 +1100
Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-30 02:04 +0000
Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 13:15 +1100
Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-29 22:39 -0400
Re: checking if two things do not equal None Rustom Mody <rustompmody@gmail.com> - 2014-03-29 19:54 -0700
Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-30 06:08 +0000
Re: checking if two things do not equal None Roy Smith <roy@panix.com> - 2014-03-30 08:21 -0400
Re: checking if two things do not equal None MRAB <python@mrabarnett.plus.com> - 2014-03-30 14:58 +0100
Re: checking if two things do not equal None Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-31 11:48 +1300
Re: checking if two things do not equal None Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-30 19:41 +1300
Re: checking if two things do not equal None Marko Rauhamaa <marko@pacujo.net> - 2014-03-30 10:37 +0300
Re: checking if two things do not equal None Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-30 05:54 +0000
Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 17:17 +1100
Re: checking if two things do not equal None Ben Finney <ben+python@benfinney.id.au> - 2014-03-30 17:52 +1100
Re: checking if two things do not equal None Chris Angelico <rosuav@gmail.com> - 2014-03-30 18:36 +1100
Re: checking if two things do not equal None Ethan Furman <ethan@stoneleaf.us> - 2014-03-29 16:20 -0700
Re: checking if two things do not equal None Terry Reedy <tjreedy@udel.edu> - 2014-03-29 19:02 -0400
Re: checking if two things do not equal None Jeremy Sanders <jeremy@jeremysanders.net> - 2014-03-31 09:56 +0200
Re: checking if two things do not equal None Abe <contact.trigon@gmail.com> - 2014-03-31 10:28 -0700
Re: checking if two things do not equal None Moritz Emanuel Beber <moritz.beber@gmail.com> - 2014-03-31 21:22 +0200
Page 1 of 2 [1] 2 Next page →
| From | contact.trigon@gmail.com |
|---|---|
| Date | 2014-03-29 11:56 -0700 |
| Subject | checking if two things do not equal None |
| Message-ID | <0245aca0-c6b7-493a-aa52-2c3ef6462dbd@googlegroups.com> |
if (a, b) != (None, None): or if a != None != b: Preference? Pros? Cons? Alternatives? :D
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-03-29 19:05 +0000 |
| Message-ID | <5337195f$0$29994$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #69337 |
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 always when people test for == to None, they don't really mean it. They actually want to use an identity test. I'm going to assume the same holds here. if not (a is b is None): ... Or if you prefer: if a is not b is not None: ... -- Steven D'Aprano http://import-that.dreamwidth.org/
[toc] | [prev] | [next] | [standalone]
| From | contact.trigon@gmail.com |
|---|---|
| Date | 2014-03-29 12:23 -0700 |
| Message-ID | <54f5af7c-a069-4452-b49d-881de94ec1cf@googlegroups.com> |
| In reply to | #69338 |
> 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.
[toc] | [prev] | [next] | [standalone]
| From | Lele Gaifax <lele@metapensiero.it> |
|---|---|
| Date | 2014-03-29 20:24 +0100 |
| Message-ID | <mailman.8696.1396121085.18130.python-list@python.org> |
| In reply to | #69338 |
Steven D'Aprano <steve+comp.lang.python@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: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.
[toc] | [prev] | [next] | [standalone]
| From | Johannes Bauer <dfnsonfsduifb@gmx.de> |
|---|---|
| Date | 2014-03-29 22:01 +0100 |
| Message-ID | <lh7cb4$ntu$2@news.albasani.net> |
| In reply to | #69338 |
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 obfuscated coding contest? Why do you opt for a solution that one has to at least think 2 seconds about when the simplest solution: if (a is not None) or (b is not None): is immediately understandable by everyone? Cheers, Johannes -- >> Wo hattest Du das Beben nochmal GENAU vorhergesagt? > Zumindest nicht öffentlich! Ah, der neueste und bis heute genialste Streich unsere großen Kosmologen: Die Geheim-Vorhersage. - Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$1@speranza.aioe.org>
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2014-03-29 17:07 -0400 |
| Message-ID | <roy-B5E8CC.17072029032014@news.panix.com> |
| In reply to | #69343 |
In article <lh7cb4$ntu$2@news.albasani.net>, Johannes Bauer <dfnsonfsduifb@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? > > > > if not (a is b is None): ... > > > > Or if you prefer: > > > > if a is not b is not None: ... > > Is this an obfuscated coding contest? Why do you opt for a solution that > one has to at least think 2 seconds about when the simplest solution: > > 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 > if (a is not None) or (b is not None): I certainly agree that things like > if a is not b is not None: ... belong in an obfuscated coding contest. Code gets read a lot more often than it get written. Make it dead-ass simple to understand, and future generations of programmers who inherit your code will thank you for it.
[toc] | [prev] | [next] | [standalone]
| From | Johannes Bauer <dfnsonfsduifb@gmx.de> |
|---|---|
| Date | 2014-03-29 22:55 +0100 |
| Message-ID | <lh7fg0$u6a$1@news.albasani.net> |
| In reply to | #69344 |
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 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 for even a rookie programmer. > I certainly agree that things like > >> if a is not b is not None: ... > > belong in an obfuscated coding contest. Code gets read a lot more often > than it get written. Make it dead-ass simple to understand, and future > generations of programmers who inherit your code will thank you for it. Absolutely. Cheers, Johannes -- >> Wo hattest Du das Beben nochmal GENAU vorhergesagt? > Zumindest nicht öffentlich! Ah, der neueste und bis heute genialste Streich unsere großen Kosmologen: Die Geheim-Vorhersage. - Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$1@speranza.aioe.org>
[toc] | [prev] | [next] | [standalone]
| From | Johannes Bauer <dfnsonfsduifb@gmx.de> |
|---|---|
| Date | 2014-03-29 23:02 +0100 |
| Message-ID | <lh7ftm$vds$1@news.albasani.net> |
| In reply to | #69346 |
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 for even a rookie programmer.
Let me expand on that thought one or two more sentences: Although it may
seem really trivial, inversions ("not") in my opinion can really make
code unreadable. One thing that I regularly see when peer-reviewing code
is something like:
if not feature_disabled:
or one that I've seen in-field (modulo the programming language and the
variable names):
if (not no_delayed_commit) and (not data_unchanged):
instead of:
if immediate_commit and data_changed:
Enough of my two cents for today :-)
Cheers,
Johannes
--
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
- Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$1@speranza.aioe.org>
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2014-03-29 18:01 -0400 |
| Message-ID | <mailman.8699.1396130164.18130.python-list@python.org> |
| In reply to | #69344 |
Roy Smith <roy@panix.com> Wrote in message:
> In article <lh7cb4$ntu$2@news.albasani.net>,
> Johannes Bauer <dfnsonfsduifb@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?
>> >
>> > if not (a is b is None): ...
>> >
>> > Or if you prefer:
>> >
>> > if a is not b is not None: ...
>>
>> Is this an obfuscated coding contest? Why do you opt for a solution that
>> one has to at least think 2 seconds about when the simplest solution:
>>
>> 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
>
>> if (a is not None) or (b is not None):
>
> I certainly agree that things like
>
>> if a is not b is not None: ...
>
> belong in an obfuscated coding contest. Code gets read a lot more often
> than it get written. Make it dead-ass simple to understand, and future
> generations of programmers who inherit your code will thank you for it.
>
The other advantage to keeping it simple is it's more than likely
to be right. If we take the original form as the spec, we'll
find that two of the alternatives are not even equivalent.
def trigon1(a, b):
return (a,b) != (None, None) #master
def trigon2(a, b):
return a != None != b. # different
def steven1(a, b):
return not(a is b is None)
def steven2(a, b):
return a is not b is not None #different
def johannes(a, b):
return (a is not None) or (b is not None)
table = [
trigon1,
trigon2,
steven1,
steven2,
johannes
]
for func in table:
print func.__name__
print func(None, None), func(None, 42), func(42, None),
func(42, 42), func(42, "never")
--
DaveA
[toc] | [prev] | [next] | [standalone]
| From | contact.trigon@gmail.com |
|---|---|
| Date | 2014-03-29 16:20 -0700 |
| Message-ID | <41055822-39c5-4783-ae95-018032cac952@googlegroups.com> |
| In reply to | #69347 |
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 make sure that both are not None. I am now considering: if None not in (a,b): or if (a is not None) and (b is not None):
[toc] | [prev] | [next] | [standalone]
| From | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| Date | 2014-03-29 17:36 -0500 |
| Message-ID | <mailman.8701.1396132615.18130.python-list@python.org> |
| In reply to | #69344 |
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 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]):
do_something_if_no_Nones()
or
if not any(x is None for x in [a, b, c, d]):
do_something_if_no_Nones()
which I find *much* more readable from a maintenance point of view.
-tkc
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-03-30 02:24 +0000 |
| Message-ID | <5337807b$0$29994$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #69350 |
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]): > do_something_if_no_Nones() > > or > > if not any(x is None for x in [a, b, c, d]): > do_something_if_no_Nones() > > which I find *much* more readable from a maintenance point of view. With one or two things, I would stick to a regular comparison (skipping the "not"): a is None a is b is None With three, I would consider either idiom: a is b is c is None all(x is None for x in (a, b, c)) but lean towards the use of all(). From four onwards I would definitely use all(), and of course if there is an arbitrary number of items, I would definitely use all(). -- Steven D'Aprano http://import-that.dreamwidth.org/
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2014-03-29 22:43 -0400 |
| Message-ID | <roy-D862BF.22430029032014@news.panix.com> |
| In reply to | #69362 |
In article <5337807b$0$29994$c3e8da3$5496439d@news.astraweb.com>, Steven D'Aprano <steve+comp.lang.python@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.
[toc] | [prev] | [next] | [standalone]
| From | Zachary Ware <zachary.ware+pylist@gmail.com> |
|---|---|
| Date | 2014-03-29 22:04 -0500 |
| Message-ID | <mailman.8711.1396148689.18130.python-list@python.org> |
| In reply to | #69364 |
On March 29, 2014 9:43:00 PM CDT, Roy Smith <roy@panix.com> wrote: >In article <5337807b$0$29994$c3e8da3$5496439d@news.astraweb.com>, > Steven D'Aprano <steve+comp.lang.python@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. I'm cryin'. (Really, that was terrible.) Walrus-ly y'rs, Zach
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2014-03-29 18:41 -0400 |
| Message-ID | <mailman.8702.1396132871.18130.python-list@python.org> |
| In reply to | #69344 |
[Multipart message — attachments visible in raw view] — view raw
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) That's even clearer if you happen to already have the items in an iterable: if set(conditions) == set(None) -- Roy Smith roy@panix.com
[toc] | [prev] | [next] | [standalone]
| From | Tim Chase <tim@thechases.com> |
|---|---|
| Date | 2014-03-29 17:46 -0500 |
| Message-ID | <mailman.8703.1396133206.18130.python-list@python.org> |
| In reply to | #69344 |
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 that as:
>
> if set([a, b, c, d]) == set(None)
>
> That's even clearer if you happen to already have the items in an
> iterable:
>
> if set(conditions) == set(None)
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
if all(x() is None for x in [func1, func2, func3, costly_func]):
do_something()
-tkc
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2014-03-29 18:51 -0400 |
| Message-ID | <roy-08D73A.18514329032014@news.panix.com> |
| In reply to | #69352 |
In article <mailman.8703.1396133206.18130.python-list@python.org>, Tim Chase <tim@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 > > > > > > 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) > > > > That's even clearer if you happen to already have the items in an > > iterable: > > > > if set(conditions) == set(None) > > Though am I correct that your iteration tests for equality, while > mine tests for identity? Hmmm, you're almost certainly correct on that, but you would have to have a perversely designed class for that to make a difference. I'll take the increased readability. > Also, my version bails early in the event > quitting early is possible. That's particularly useful in the case > of doing something like > > if all(x() is None for x in [func1, func2, func3, costly_func]): > do_something() Again, you're correct. But, I'll take the increased readability over the premature optimization :-)
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-03-30 10:17 +1100 |
| Message-ID | <mailman.8705.1396135079.18130.python-list@python.org> |
| In reply to | #69344 |
On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase <tim@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 > > if all(x() is None for x in [func1, func2, func3, costly_func]): > do_something() Presumably you mean to actually call those functions, as checking the identity of a costly function is still cheap :) ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| Date | 2014-03-29 20:19 -0500 |
| Message-ID | <mailman.8707.1396142341.18130.python-list@python.org> |
| In reply to | #69344 |
On 2014-03-30 10:17, Chris Angelico wrote:
> On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase <tim@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
>>
>> if all(x() is None for x in [func1, func2, func3, costly_func]):
^^^
>> do_something()
>
> Presumably you mean to actually call those functions, as checking
> the identity of a costly function is still cheap :)
Which is what I do...calling only those necessary until the all/any
condition has been met. :-)
If you create the list of things to iterate over by calling them as
you create the list, then you don't save much of anything. If you
only call until one of them breaks the any/all construct, you save
all the subsequent function calls.
-tkc
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-03-30 12:37 +1100 |
| Message-ID | <mailman.8708.1396143451.18130.python-list@python.org> |
| In reply to | #69344 |
On Sun, Mar 30, 2014 at 12:19 PM, Tim Chase <python.list@tim.thechases.com> wrote: > On 2014-03-30 10:17, Chris Angelico wrote: >> On Sun, Mar 30, 2014 at 9:46 AM, Tim Chase <tim@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 >>> >>> if all(x() is None for x in [func1, func2, func3, costly_func]): > ^^^ >>> do_something() >> >> Presumably you mean to actually call those functions, as checking >> the identity of a costly function is still cheap :) > > Which is what I do...calling only those necessary until the all/any > condition has been met. :-) > > If you create the list of things to iterate over by calling them as > you create the list, then you don't save much of anything. If you > only call until one of them breaks the any/all construct, you save > all the subsequent function calls. *facepalm* Yep, you do indeed. My bad! Take no notice of the man behind the curtain... ChrisA
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.python
csiph-web