Paul Rubin wrote:
Ethan Furman writes:
Or if any(p for p in [header, body, footer, whatever, ...])
No need for the genexp:
if any([header, body, footer, whatever, ...])
But, you are using the built-in bool cast either way.
Right you are -- and
if any([header, body, footer, whateve
Ethan Furman writes:
> Or if any(p for p in [header, body, footer, whatever, ...])
No need for the genexp:
if any([header, body, footer, whatever, ...])
But, you are using the built-in bool cast either way.
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
On Fri, 17 Jul 2009 16:09:03 +0100, MRAB wrote:
Python did always have True and False.
Oops! I meant "didn't", of course.
$ python1.5
Python 1.5.2 (#1, Apr 1 2009, 22:55:54) [GCC 4.1.2 20070925 (Red Hat
4.1.2-27)] on linux2
Copyright 1991-1995 Stichting Mathematis
Steven D'Aprano writes:
> Since I haven't specified an implementation for assemble_page, it could
> be doing *anything*. Perhaps it has to talk to a remote database over a
> slow link, perhaps it generates 300 lines of really inefficient HTML code
> with no content, perhaps it sends a print job
Paul Rubin wrote:
Steven D'Aprano writes:
def assemble_page(header, body, footer):
if header or body or footer:
do_lots_of_expensive_processing()
else:
do_nothing_gracefully()
Why should the processing be expensive if all three fields are empty?
if header or body o
On Fri, 17 Jul 2009 16:09:03 +0100, MRAB wrote:
> Python did always have True and False.
$ python1.5
Python 1.5.2 (#1, Apr 1 2009, 22:55:54) [GCC 4.1.2 20070925 (Red Hat
4.1.2-27)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> True, False
Traceback (innermost last
On Fri, Jul 17, 2009 at 11:09 AM, MRAB wrote:
> Python did always have True and False.
Only if "always" means "since python 2.2.1".
See: http://www.python.org/doc/2.3/whatsnew/section-bool.html and
http://www.python.org/dev/peps/pep-0285/ for details.
--
Jerry
--
http://mail.python.org/mailma
koranthala wrote:
That test was designed to treat None as a boolean False, without
noticing that numeric 0 is also treated as False and could make the
test do the wrong thing. This is an extremely common type of error.
Actually, I felt that 0 not being considered False would be a better
option
On Fri, 17 Jul 2009 07:12:51 -0700, Paul Rubin wrote:
> Steven D'Aprano writes:
>> def assemble_page(header, body, footer):
>> if header or body or footer:
>> do_lots_of_expensive_processing()
>> else:
>> do_nothing_gracefully()
>
> Why should the processing be expensive
Steven D'Aprano writes:
> def assemble_page(header, body, footer):
> if header or body or footer:
> do_lots_of_expensive_processing()
> else:
> do_nothing_gracefully()
Why should the processing be expensive if all three fields are empty?
> if header or body or footer:
On Fri, 17 Jul 2009 00:34:00 -0700, Paul Rubin wrote:
> Steven D'Aprano writes:
>> It is very useful to be able to write e.g.:
>>
>> if header or body or footer:
>> print assemble_page(header, body, footer)
>>
>> and have empty strings to be equivalent to False.
>
> Why doesn't assemble_pag
Steven D'Aprano writes:
> It is very useful to be able to write e.g.:
> if header or body or footer:
> print assemble_page(header, body, footer)
> and have empty strings to be equivalent to False.
Why doesn't assemble_page properly handle the case where header, body,
and footer are all empty?
On Thu, 16 Jul 2009 23:13:51 -0700, koranthala wrote:
>> That test was designed to treat None as a boolean False, without
>> noticing that numeric 0 is also treated as False and could make the
>> test do the wrong thing. This is an extremely common type of error.
>
> Actually, I felt that 0 not
On Thu, Jul 16, 2009 at 11:13 PM, koranthala wrote:
>> That test was designed to treat None as a boolean False, without
>> noticing that numeric 0 is also treated as False and could make the
>> test do the wrong thing. This is an extremely common type of error.
>
> Actually, I felt that 0 not bein
> That test was designed to treat None as a boolean False, without
> noticing that numeric 0 is also treated as False and could make the
> test do the wrong thing. This is an extremely common type of error.
Actually, I felt that 0 not being considered False would be a better
option.
I had lot of
15 matches
Mail list logo