kristofer / Bard's grep Intro
Last active
Verily, grep
is a most puissant tool in the hands of a programmer, especially when one must
search through vast tomes of code or scrolls of logs.
Picture this scene: thou art a developer, toiling on a grand project with countless lines of code.
Thou dost suspect a bug lieth within a function known as processData.
Rather than peruse each folio by hand, thou canst employ grep to swiftly find all instances of processData
within thy code.
Example Command:
kristofer / TastyHints.md
Last active
Lab notes on getting going thru the early parts of Tasty lab.
Tasty Lab Hints
Lab notes on getting going thru the early parts of Tasty.
Hint 0
Remember start very small and build outward. The class/program already works, run it and see.
Hint 1
kristofer / TastyHint3.md
Last active
I'm struggling to see where we take the user input for the task name.
the command
variable will have exit
or whatever, right?
and the new <task>
will actually look like new Buy Milk
so take the string and split it into a list of strings, breaking each string on the character.
kristofer / TastyHint2.md
Last active
If we have thought about this:
tasks = {} # creates an empty dictionary
tasks['Buy Milk'] = 'not yet'
tasks['Start Lab'] = 'completed'
kristofer / TastyHint1.md
Last active
Remember start very small and build outward.
Hint 1
If you haven't already decided how to start...
This is the tasks
variable.
Tasty class.
kristofer / Some Bad Habits in Python
Last active
One More List of Bad Habits
Also, be aware that some of these things are not actually related to Python but are considered to be bad practices in most of the languages (like Java).
- No comments is bad — people forget and you should comment your code. Describe why not how. Explain the intent behind the code.
- Too many comments is also bad — you should feel the border line at column 80.
- No abstractions is bad — they didn’t develop Python for you to write Assembly-style wall of code with no functions and/or classes. Copy-pasting your code is bad — use functions when you
kristofer / Is Pythonic?
Last active
some examples of good and bad pythonic snippets
Pythonic" code refers to code that is written in a way that is idiomatic to Python, taking advantage of its features and conventions to produce clear, concise, and readable code. Here are some examples showcasing Pythonic principles:
1. List Comprehensions
Not Pythonic:
squares = []
kristofer / dict-count.py
Last active
a sample of frequency counting words from a list, in good and bad styles
1 | # You need to write a loop that counts the occurrences of each word in a list. |
2 | # |
3 | # Consider, if you had a big str that was a text, like say: https://zcw.guru/kristofer/hamlet |
4 | # |
5 | # strive to be "pythonic" in your code expressions, okay? |
6 | |
7 | colors = ["red", "green", "blue", "green", "red", "green"] |
8 | |
9 | # Not Pythonic Code |
10 | d = {} |
kristofer / Hamlet by Shake-speare
Last active
1 | THE TRAGEDY OF HAMLET, PRINCE OF DENMARK |
2 | |
3 | |
4 | by William Shakespeare |
5 | |
6 | |
7 | |
8 | Dramatis Personae |
9 | |
10 | Claudius, King of Denmark. |