
Nov. 8, 2008
8:05 p.m.
Jim Jewett wrote:
On Thu, Nov 6, 2008 at 3:31 PM, George Sakkis <george.sakkis@gmail.com> wrote:
Several times I find myself using the following idiom:
_Missing = object() # sentinel
def foo(x, y=_Missing): if y is _Missing: do_this else: do_that
And I often catch myself trying to write
def foo(x, y=object()): if y is ... # oops, I need to define the y *outside* the function.
if type(y) is object: ... And no, there is no problem if a foolish caller passes an object(), because such has no meaning other than what your sentinal y means.