Do not use this for SQL query generation. Use the database driver SQL parameters instead. You cannot hope to properly escape your way out of SQL injection attacks otherwise.
If you need to use a WHERE .. IN ..
test, generate placeholders:
query = 'SELECT * FROM table WHERE column IN ({})'.format(','.join(['%s'] * len(lst)))
cursor.execute(query, lst)
For everything else, use a list comprehension to add the quotes to the values, then join the results with commas:
', '.join(['"{}"'.format(value) for value in lst])
Demo:
>>> lst = ['John','Jack','Martin']
>>> ', '.join(['"{}"'.format(value) for value in lst])
'"John", "Jack", "Martin"'
>>> print ', '.join(['"{}"'.format(value) for value in lst])
"John", "Jack", "Martin"
This will consistently use "
double quotes; simply use "'{}'"
as the template if you must have single quotes instead.