rabingaire / never_kill_your_time

A simple script that creates push notification on gnome desktop environment to remind your routine.
MIT License
14 stars 5 forks source link

Adhere to Python best practices #14

Open nmunro opened 7 years ago

nmunro commented 7 years ago

The following snippet:

json_data=open("/bin/routine.json").read()
data = json.loads(json_data)

Would be better written as:

data = None
with open("/bin/routine.json") as f:
  data = json.loads(f.readlines())

The with statement ensures that the file is never left open accidentally.

tarunvelli commented 7 years ago

@nmunro thanks for pointing it out. And i used f.read() instead of f.readlines() as data is in list format.

rabingaire commented 7 years ago

Wow Code is becoming better and better :)

rabingaire commented 7 years ago

And by the way @tarunvelli you did such a great job, I am trying to grasp what you did there. I am just beginning to learn python so it's quite confusing for me to understand the whole code. But I am happy that I am able to learn from you :)

tarunvelli commented 7 years ago

Hey my code is pretty hacky, im sure its not the right way to do it. But works fine for now :) do improve on it when you get better implementations

rabingaire commented 7 years ago

Sure I will look forward making the code better and useful. Thank you again for your time. You did super cool thing :)