fileindex

sisl.utils.fileindex(f, cast=int)[source]

Parses a filename string into the filename and the indices.

This range can be formatted like this:

file[1,2,3-6]

in which case it will return:

file, [1,2,3,4,5,6]

Parameters:
  • f (str) – filename to parse

  • cast (function) – the function to cast the bracketed value

Examples

>>> fileindex("Hello[0]")
("Hello", 0)
>>> fileindex("Hello[0-2]")
("Hello", [0, 1, 2])