def to_ps(obj, parlen=False):
    """Converts object into postscript literal

    >>> to_ps(None)
    'null'
    >>> to_ps(123)
    '123'
    >>> to_ps(456.78)
    '456.78'
    >>> to_ps(True), to_ps(False)
    ('true', 'false')
    >>> to_ps('foo bar baz')
    'foo bar baz'
    >>> to_ps('foo bar baz', parlen=True)
    '(foo bar baz)'

    """
    if isinstance(obj, str):
        ret = '%s' % obj
        if parlen:
            ret = '(%s)' % ret
    elif isinstance(obj, bool):
        ret = {True: 'true', False: 'false'}[obj]
    elif isinstance(obj, type(None)):
        ret = 'null'
    else:
        ret = str(obj)
    return ret