Python builtin function as keyword argument default?
<p>Are Python's built-in functions not available for use as keyword defaults, or should I be using some other way of referring to a function?</p>

<p>I wanted to write a function like this:</p>

<pre><code>def isPNGBlock(bytes, blockLen, pngOffset=0, pngErrorLogger=print):
    ...
    try:
        r.validate_signature()
        width, height, pixels, metadata = r.read(lenient=True)
    except png.Error as e:
        pngErrorLogger(e)
</code></pre>

<p>Instead I've had to settle for doing this with a default argument of None as a flag value.</p>

<pre><code>def isPNGBlock(bytes, blockLen, pngOffset=0, pngErrorLogger=None):
    ...
    try:
        r.validate_signature()
        width, height, pixels, metadata = r.read(lenient=True)
    except png.Error as e:
        if pngErrorLogger is None:
            print(e)
        else:
            pngErrorLogger(e)
</code></pre>

<p>or using a wrapper function:</p>

<pre><code>def defaultLogger(str):
    print(str)

def isPNGBlock(bytes, blockLen, pngOffset=0, pngErrorLogger=defaultLogger ):
    ...
    try:
        r.validate_signature()
        width, height, pixels, metadata = r.read(lenient=True)
    except png.Error as e:
        pngErrorLogger(e)
</code></pre>
