Idiom gone, or did it really ever exist? () is ()
Duncan Booth
duncan at NOSPAMrcp.co.uk
Wed Apr 18 05:17:39 EDT 2001
"Mike C. Fletcher" <mcfletch at home.com> wrote in
<mailman.987578846.15784.python-list at python.org>:
> You want this kind of construct when creating "generic services" that
> can process any object type (including None), so need to be able to
> determine whether the object passed is, in fact, the value None, or
> merely the absence of a value.
>
>
So why not use the portable and safe way of finding out whether your
function was called with a particular argument or not?
def foo(**kw):
validargs = { 'bar': None }
validargs.update(kw)
assert len(validargs)==1
if kw.has_key('bar'):
print "Have bar"
else:
print "No bar"
--
Duncan Booth
duncan at dales.rmplc.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list