def snapstr(number):
    """
    return formatted string for snapshot number
    (4 digit, zero padded string). Can take both
    strings and integers as argument.
    """
    if hasattr(number, '__len__') and not isinstance(number, str):
        print(
            "You've given me a list for a snapshot number? I'm going to try element 0:"
            , number[0])
        number = number[0]
    errormsg = "'" + str(number) + "' is not an integer."
    if isinstance(number, float):
        raise ValueError(errormsg)
    import numpy as np
    try:
        n = int(number)
    except ValueError:
        raise ValueError(errormsg)
    return '{0:04d}'.format(n)
