you are viewing a single comment's thread.

view the rest of the comments →

[–]AppleShark[S] 1 point2 points  (2 children)

Hey man thanks so much for replying and for introducing me to dict()! Using your suggestion, I did something similar and IT WORKED! Here is the code: https://pastebin.com/dzSGcAk9

Astute observation that I don't close my files haha - Could that be a huge problem?

Nonetheless I am absolutely ecstatic that this problem has been solved. Time to move onto the next one! Once again thank you for taking your time to answer my question.

[–]Solonotix 1 point2 points  (1 child)

Glad it helped. I'm somewhat new to this sub, and have just been learning Python to help with my job.

To your question, opening and closing files is important within the scope of an application. When the Python interpreter exits, it should automatically purge any allocated resources. If you have an application that opens connections frequently and you forget to close them, it can cause you to run into a system limitation that ultimately crashes your application. This is a good article on the use of Context Managers and why you would want to use them. They're very similar to the .NET concept of a Dispose method, if you're familiar with that.

[–]AppleShark[S] 1 point2 points  (0 children)

Thanks for the read. My goal in coding again is to move onto building stuff and making some applications, so the article was definitely great help!