"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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4