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
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
-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
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