DeaD_EyE icon

creating wrong encoded filenames

DeaD_EyE | PRO | 01/01/23 02:14:56 PM UTC | 0 ⭐ | 1959 👁️ | Never ⏰ | []
Python |

560 B

|

None

|

0 👍

/

0 👎

from random import randint, choice
 
 
def get_char():
    return randint(1, 255)
 
def make_file_name():
    return bytes(get_char() for _ in range(randint(5, 10)))
    
def create_files(n):
    for _ in range(n):
        try:
            open(make_file_name(), "w").close()
        except (FileNotFoundError, IsADirectoryError):
            # don't ask, why there could be a IsADirectoryError
            # but it demostates how bad it is to use broken unicode
            # for filenames
            pass
 
 
if __name__ == "__main__":
    create_files(20)
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎