How do you generate all the permutations of a list in Python, independently of the type of elements in that list?

For example:

permutations([])

[]

permutations([5])

[5]

permutations([1, 5])

[1, 5]

[5, 1]

permutations([1, 5, 7])

[1, 5, 7]

[1, 7, 5]

[5, 1, 7]

[5, 7, 1]

[7, 1, 5]

[7, 5, 1]