Question on keyword arguments

grsmith at atlanticbb.net grsmith at atlanticbb.net
Thu Feb 18 09:00:10 EST 2016


Would this be the correct way to return
a list as a default result.

Also, would the list be the preferable result (to a python programmer) ?

def test(command, return_type='LIST'):
    """ Go to database and return data"""
    if return_type == 'LIST':
        result = ['ONE', 'TWO', 'THREE']
    else:
        result = r'0xfeONE\0exfeTWO\0xfeTHREE'
    return result

if __name__ == '__main__':
    print(test('cmd'))
    print(test('cmd', 'LIST'))
    print(test('cmd', None))
    print(test('cmd', 'string'))


thanks,
george


More information about the Python-list mailing list