[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: Use cases for del
From: "Steven D'Aprano" <steve () REMOVEMEcyber ! com ! au>
Date: 2005-07-07 8:24:58
Message-ID: 42CCE6DA.5020402 () REMOVEMEcyber ! com ! au
[Download RAW message or body]
Ron Adam wrote:
> Why would you want to use None as an integer value?
>
> If a value isn't established yet, then do you need the name defined?
> Wouldn't it be better to wait until you need the name then give it a value?
Er, maybe I'm misunderstanding something here, but
surely the most obvious case is for default and special
function arguments:
def count_records(record_obj, start=0, end=None):
if end == None:
end = len(record_obj)
if start == None: # this is not the default!
# start at the current position
start = record_obj.current
n = 0
for rec in record_obj.data[start:end]:
if not rec.isblank():
n += 1
return n
which you call with:
# current position to end
count_records(myRecords, None)
# start to end
count_records(myRecords)
# start to current position
count_records(myRecords, end=myRecords.current)
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic