r/learnpython • • May 30 '20

Python cheat sheet?

I was wondering whether you guys keep a handy cheat sheet when y'all code. For example when working with a module after a long time it's obvious that we become rusty and need help with the functions and the syntax. Would be great if you guys share the links/books that you guys refer to while programming. I'm sorry if this has been asked before. Cheers!

372 Upvotes

50 comments sorted by

View all comments

1

u/ragnar_the_redd Jun 01 '20

Well except for the obvious (stack overflow).
Whenever i do something new in python, for work or part of any large project, I create an experiment entry in my private repository.

I take the new library or concept, or even just a complex data processing function i need to include in the big scale project and do it on a small scale. I often forget how i do things, and i can always return to the specific experiment to see it.

A lot of it goes out of date as external libraries or even python itself gets updated (well honestly just the 2.7 - 3.75 switch) But since it is short and focused i can simply look at it and remember what, how and why i did.

For example i once ran into some trouble with base64 encode decode - real basic stuff for people who work with it daily, but for me it was complicated because data went in right, but the receiving side failed to process because - as i know now - it didn't come out because of the way dict type objects were encoded.
Took me a couple of hours to understand that i have a problem, where i have it and why it's happening.
So now i have a "base64_experiment" where i have an example of structure sensitive encode/decode for various models.

That's my personal cheat sheet.