peertube-headless-seeder icon indicating copy to clipboard operation
peertube-headless-seeder copied to clipboard

Fix how Python Accesses TXT Files

Open tyrsarm opened this issue 1 year ago • 0 comments

          I would argue that it along with [these lines](https://github.com/tyrsarm/peertube-headless-seeder/blob/05139f00f419287c6960d5e4246ee832d0a97bf9/playlive.py#LL24-L27) would be the issue as this just opens a file to write, passes, then closes before doing the write that you mentioned.

In Python, it best to use the

with open('file.txt', 'w') as f:
    f.write("Text for the file")

because using the with will automatically handle opening and closing the file for you so you don't have to worry about it. I think the author didn't realize that is how it worked and did a pass on them and then manually opened and close it themselves.

Originally posted by @CGBassPlayer in https://github.com/tyrsarm/peertube-headless-seeder/issues/5#issuecomment-1469069153

tyrsarm avatar Mar 31 '23 00:03 tyrsarm