title: Default argument alternative to None?
body: <p>I am writing a function a little like this:</p>
  
  <pre><code>def parse(string, default=None):
      try:
          ...  # Body of function here
      except ParseError:
          if default is not None:
              return default
          raise
  </code></pre>
  
  <p>But then I run into problems if I actually want the function to return <code>None</code>.</p>
  
  <pre><code>if len(sys.argv) &gt; 4:
      if flag.ignore_invalid:
          result = parse(sys.argv[4], None)  # Still raises error
      else:
          result = parse(sys.argv[4])
  </code></pre>
  
  <p>What I have tried to fix this is:</p>
  
  <pre><code>_DEFAULT = object()
  
  def parse(string, default=_DEFAULT):
      ...
          if default is not _DEFAULT:
              ...
  </code></pre>
  
  <p>But this seems like I'm overthinking it, and it seems like there's an easier way to do it.</p>
  
  <p>The <code>any</code> and <code>all</code> functions do this (Allowing <code>None</code> as a default), but I don't know how.</p>