Idiom gone, or did it really ever exist? () is ()
Michael Haggerty
mhagger at alum.mit.edu
Thu Apr 19 17:04:12 EDT 2001
More information about the Python-list mailing list
Thu Apr 19 17:04:12 EDT 2001
- Previous message (by thread): Idiom gone, or did it really ever exist? () is ()
- Next message (by thread): why use /bin/sh -c in popen2(3/4)?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Delaney, Timothy" <tdelaney at avaya.com> writes: > > > That is, I was attempting to distinguish between a call where > > > argument is passed a NULL tuple and a call where argument is > > > passed nothing at all. > > # Should always work > > class nullArgument: > """""" > > __nullArgument = nullArgument() > > def func (p=__nullArgument): > if p is __nullArgument: > print 'Default parameter' > else: > print 'Parameter passed' When I first faced this problem, I started typing in code that was equivalent to yours, until it occurred to me that there is no reason to instantiate the class--the class itself serves as a fine default argument. In other words, class __nullArgument: pass # Isn't this what pass is for? def func (p=__nullArgument): if p is __nullArgument: print 'Default parameter' else: print 'Parameter passed' Cheers, Michael -- Michael Haggerty mhagger at alum.mit.edu
- Previous message (by thread): Idiom gone, or did it really ever exist? () is ()
- Next message (by thread): why use /bin/sh -c in popen2(3/4)?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list