r/learnpython • • Dec 23 '19

What are some creative small programs that you have coded using Python?

I am a beginner at coding with Python, so I am curious about learning what small programs or projects you all have created. I am hoping to develop my skills using Python, so I figured looking at actual code for various programs would greatly help.

Please include a short description of what the program does and the code itself in the comments below. Thank you!

348 Upvotes

224 comments sorted by

View all comments

20

u/DemDim1 Dec 23 '19 edited Dec 23 '19

I have a side job where I can decide my own hours, so I wrote a program that automatically schedules work in my agenda on days where I don't have anything important. I'm at work now, so I'll include the code later.

Edit: https://pastebin.com/0JY7YZZk
This is the code, I added some comments to hopefully make it a bit more readable, since the script mostly messes with Google's API and datetime/dateutil. If you want some more info I'll be happy to help.

1

u/[deleted] Dec 30 '19

u/DemDim1 I tried to run this code but I keep getting an error when running it. Any help would be wonderful

AttributeError: 'NoneType' object has no attribute 'refresh'

>>> if not credentials or not credentials.valid:

... if credentials and credentials.expired and credentials.refresh_token:

... credentials.refresh(Request())

... else:

... flow = InstalledAppFlow.from_client_secrets_file("credentials.json", SCOPES)

... credentials = flow.run_local_server(port=0)

1

u/DemDim1 Dec 30 '19

Do you have a credentials.json file?

1

u/[deleted] Dec 31 '19

I created an empty credentials.json and now I get this error

raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

What am I suppose to put in credentials.json?

Thanks for your help btw.

1

u/DemDim1 Dec 31 '19

You need to get credentials for your google account, you can download them as a json (and they will be encrypted)

1

u/NameTaken_was_taken Dec 23 '19

RemindMe! 1 day

0

u/anoldmuff Dec 23 '19

RemindMe! 6 hours

0

u/[deleted] Dec 23 '19

RemindMe! 5 days