All New

user:thomas gists created by user

title:mygist gists with given title

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

Login


All New
's Avatar

kristofer

Joined 1714567308

Recently created
Least recently created
Recently updated
Least recently updated
All gists 105
kristofer's Avatar

kristofer / JSON Intro

0 likes
0 forks
1 files
Last active 1731508068

Introduction to JSON

JSON, or JavaScript Object Notation, is a lightweight data interchange format that is easy for humans to read and write, and easy for machines to parse and generate. It has become an essential tool for programmers, particularly in web development, due to its simplicity and versatility.

Why JSON is Important to Programmers

Ease of Use: JSON's straightforward syntax makes it accessible to both new and experienced programmers. Its structure is composed of key-value pairs, much like a dictionary in Python or an object in JavaScript.

Language Independence: JSON is language-agnostic, meaning it can be used with almost any programming language. Whether you're working with JavaScript, Python, Java, or any other language, JSON is widely supported and easy to integrate.

kristofer's Avatar

kristofer / Bard's grep Intro

0 likes
0 forks
1 files
Last active 1731507075

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's Avatar

kristofer / Why PIP?

0 likes
0 forks
1 files
Last active 1731508154
why is PIP needed when learning python?

Why PIP?

"pip install" is crucial in the Python ecosystem for several reasons:

Imagine you're building a web application: You might need various libraries to handle web frameworks, database connections, or even data visualization. While Python comes with a rich standard library, many powerful tools and packages are not included by default. Here's where "pip install" comes into play.

kristofer's Avatar

kristofer / TastyHints.md

0 likes
0 forks
1 files
Last active 1731423730
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's Avatar

kristofer / TastyHint3.md

0 likes
0 forks
1 files
Last active 1731421149

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's Avatar

kristofer / TastyHint2.md

0 likes
0 forks
1 files
Last active 1731350954

If we have thought about this:


tasks = {}   # creates an empty dictionary

tasks['Buy Milk'] = 'not yet'
tasks['Start Lab'] = 'completed'
kristofer's Avatar

kristofer / TastyHint1.md

0 likes
0 forks
1 files
Last active 1731350546

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's Avatar

kristofer / Some Bad Habits in Python

0 likes
0 forks
1 files
Last active 1731081231

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's Avatar

kristofer / Is Pythonic?

0 likes
0 forks
1 files
Last active 1731080194
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's Avatar

kristofer / dict-count.py

0 likes
0 forks
1 files
Last active 1731079542
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 = {}
Newer Older

Powered by Opengist ⋅ Load: 240ms⋅

English
Čeština Deutsch English Español Français Magyar Português Русский 中文 繁體中文