python-snippets/utils/misc_utils.py
2024-07-17 22:30:12 +01:00

17 lines
316 B
Python

from random import shuffle
def immutable_to_list(immutable, scramble=False, prune=0):
indices = list(range(len(immutable)))
if scramble:
shuffle(indices)
python_list = [immutable[i] for i in indices]
if prune > 0:
del python_list[prune:]
return python_list