Re: [Python-Dev] nodef

2007-05-23 Thread Raymond Hettinger
From: "Greg Ewing" > If the aforementioned iterable can yield *anything*, > then it might yield this 'nodef' value as well. > > For this reason, there *can't* exist any *standard* > guaranteed-unambiguous sentinel value. Each use > case needs its own, to ensure it's truly unambiguous > in the con

Re: [Python-Dev] nodef

2007-05-23 Thread Greg Ewing
Martin Blais wrote: > I don't know > what lives in the iterable, so why should I make assumptions? > > I think Python needs a builtin for this very purpose. I propose > 'nodef', a unique object whose sole purpose is to serve as a default > value. If the aforementioned iterable can yield *anythin

Re: [Python-Dev] nodef

2007-05-23 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On May 23, 2007, at 8:08 PM, Martin Blais wrote: > I often have the need for a generic object to use as the default value > for a function parameter, where 'None' is a valid value for the > parameter. I do the same thing for 'get' calls, where None i

[Python-Dev] nodef

2007-05-23 Thread Martin Blais
Hi I often have the need for a generic object to use as the default value for a function parameter, where 'None' is a valid value for the parameter. For example: _sentinel = object() def first(iterable, default=_sentinel): """Return the first element of the iterable, otherwise th