[Python-Dev] python-dev Summary for 2003-04-16 through 2003-04-30

Tim Peters tim.one@comcast.net
Fri, 02 May 2003 15:59:40 -0400


[Brett Cannon]
> ...
> But the function still got added for numbers.  So, as of Python 2.3b1,
> there is a built-in named 'sum' that has the parameter list
> "sum(list_of_numbers [, start=0]) -> sum of the numbers in
> list_of_numbers".  The 'start' parameter allows you to specify where to
> start in the list for your running sum.

list_of_numbers is really any iterable producing numbers.

All the numbers are added ("start" doesn't affect that), as if via

def sum(seq, start=0):
    result = start
    for x in seq:
        result += x
    return start

The best use for start is if you're summing a sequence of number-like
arguments that can't be added to the integer 0 (datetime.timedelta is an
example).

> ...
> Python, the gift that keeps on giving you more responsibility.  =)

Speaking of which, your PSF dues for April are overdue <wink>.

> ...
> `os.path.walk() lacks 'depth first' option`__
>     Someone requested that os.path.walk support depth-first walking.

This was a terminology confusion:  os.path.walk() always did depth-first
walking, and so does the new os.walk().  The missing bit was an option to
control whether directories are delivered in preorder ("top down") or
postorder ("bottom up") during the depth-first walk.

> The request was deemed not important enough to bother implementing,

A topdown flag is implemented in os.walk().