How come enumerate does not produce a sequence?
----> 1 BytesInt('1B')
12 def BytesInt(s):
13 suffixes = ['B','KB','MB','GB','TB','PB','EB','ZB','YB']
---> 14 for power,suffix in reversed(enumerate(suffixes)):
15 if s.endswith(suffix):
16 return int(s.rstrip(suffix))*1024**power
TypeError: argument to reversed() must be a sequence
enumerate
indeed does not return a sequence, it is a generator. If your input is relatively small you can convert it to a list:
for power, suffix in reversed(list(enumerate(suffixes))):