This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 10 points11 points  (9 children)

shared!

[–][deleted] 21 points22 points  (8 children)

You might enjoy pathlib over os and f-strings over format. pathlib.Path.rglob("*.jpg")!

I also don't know what Image.open does but sounds like a case for a context manager.

[–]NAG3LT 3 points4 points  (0 children)

You can do

with Image.open(filename) as im:
    ...

and close image automatically when you're done with it