this will double-quote output ... just do 'print' if serializer is set.

if you like cleverish code you can write

formatter = (serializer.dumps if serializer else pprint.pformat)
print formatter(result)