The Python Coding Stack • by Stephen Gruppetta

The Python Coding Stack by Stephen Gruppetta delivers Python programming insights using narratives and stories, aimed at learners at all levels. It covers a wide range of Python-specific topics such as object-oriented programming, lambda functions, NumPy, class inheritance, Python data structures, animations with turtle and Matplotlib, and method definitions, among others.

Object-Oriented Programming Python Functions Python Data Structures Python Classes and Inheritance Programming Tutorials and Guides Software Development Best Practices Data Handling and Analysis Python Libraries and Modules Interactive Programming and Animations

The hottest Substack posts of The Python Coding Stack • by Stephen Gruppetta

And their main takeaways
179 implied HN points 27 Oct 24
  1. In Python, each function has its own scope. This means a variable defined in a function can only be used inside that function, not outside.
  2. The LEGB rule helps Python find variables: it first looks in the Local scope, then in any Enclosing scopes, next in the Global scope, and finally in Built-in scope if it can't find the variable anywhere else.
  3. Namespaces are like containers for names in Python. They store the names of variables and their corresponding values, making it clear which variables are available in which parts of your code.
259 implied HN points 13 Oct 24
  1. In Python, lists don't actually hold the items themselves but instead hold references to those items. This means you can change what is in a list without changing the list itself.
  2. If you create a list by multiplying an existing list, all the elements will reference the same object instead of creating separate objects. This can lead to unexpected results, like altering one element affecting all the others.
  3. When dealing with immutable items, such as strings, it doesn't matter if references point to the same object. Since immutable objects cannot be changed, there are no issues with such references.
239 implied HN points 01 Dec 23
  1. Python's `lambda` functions are just functions with no name and a single expression.
  2. You can use `lambda` functions as disposable, inline anonymous functions when needed.
  3. While `lambda` functions are useful, you can always use standard functions instead if you prefer.
199 implied HN points 29 Dec 23
  1. The post includes a brief overview of the past year and what's coming up in 2024.
  2. There's a reader survey on code blocks preferences, with two options presented.
  3. The article includes a tutorial on creating Python animations using the turtle module, including moving dots on a sphere.
Get a weekly roundup of the best Substack posts, by hacker news affinity:
199 implied HN points 07 Dec 23
  1. The `key` parameter is found in various Python functions like `sorted()` and `.sort()` and is used to customize the sorting logic based on a specified rule.
  2. By using the `key` parameter in functions like `sorted()`, you can sort items in a list based on unique criteria such as length or specific characters in a name.
  3. `key` parameter is not limited to sorting functions like `sorted()`, `max()`, and `min()`, but can also be found in other functions like `groupby()` in the `itertools` module.
119 implied HN points 10 Feb 24
  1. You can use Matplotlib to create animations, like a mosaic of previous article cover images, by following a step-by-step tutorial.
  2. Before starting the animation, ensure you have images ready and the necessary libraries installed like Matplotlib, NumPy, and Pillow.
  3. You can control how images are plotted, resize images in the animation frames, and save the animation as a movie file like an mp4 or an animated GIF using libraries like Matplotlib or PillowWriter.
119 implied HN points 30 Jan 24
  1. The next article will be a milestone on The Python Coding Stack.
  2. The number of subscribers doesn't matter to the author.
  3. The author will be sharing important milestones in Python tutorial articles.
338 implied HN points 23 Apr 23
  1. Year 1 covers the mindset needed for object-oriented programming
  2. The series progresses with defining classes and learning about data attributes in Year 2
  3. By Year 3, methods within classes are introduced to students
219 implied HN points 15 Jun 23
  1. Students at Hogwarts School of Codecraft and Algorithmancy learn about inheritance in their fifth year.
  2. Inheritance in Python classes is similar to inheriting characteristics from parents while also having unique traits.
  3. Child classes inherit attributes from parent classes but can modify them and introduce new attributes.
239 implied HN points 03 May 23
  1. The article discusses the progression of Python OOP series at Hogwarts School of Codecraft and Algorithmancy from a philosophical outlook to practical aspects like defining classes and learning about data attributes.
  2. The curriculum is structured as a series of seven articles, each linked to a specific year at Hogwarts, covering topics such as defining methods, interactions between classes, inheritance, special methods, class methods, and static methods.
  3. The article explains the process of creating classes, defining data attributes, and initializing instances by utilizing special methods like __init__() and understanding the significance of using 'self' as a placeholder for the object itself within a class definition.
199 implied HN points 28 May 23
  1. Python's `turtle` module can be used to create complex and interactive animations, not just simple shapes.
  2. Creating animations step-by-step gives insight into the progression of writing a program and allows control over moving parts.
  3. Adding user interaction like controlling rotation speed and toggling edge behavior enhances the interactivity and dynamics of the animation.
219 implied HN points 28 Apr 23
  1. Sequences in Python are different from iterables because sequences can be indexed using integers.
  2. Common sequences in Python include lists, strings, and tuples, which must have a defined length.
  3. Not all iterables are sequences; for example, dictionaries and sets are iterable but not indexable with integers like sequences.
179 implied HN points 10 Jun 23
  1. In the fourth year at Hogwarts School of Codecraft and Algorithmancy, students learn more about methods and interaction between different classes.
  2. The curriculum at Hogwarts covers different aspects of object-oriented programming over seven years, starting with mindset up to class methods and static methods.
  3. By passing information between objects of different classes, such as wizards and wands, one can create more complex and interconnected operations in Python programming.
159 implied HN points 02 Jul 23
  1. The article explores the `__getitem__()` special method in Python, focusing on using different data types within square brackets to fetch data.
  2. A new `Library` class is introduced, where the `__getitem__()` method is defined to fetch books based on index, author name, or book name.
  3. The code examples demonstrate creating instances of `Book` and `Library`, adding books to the library, and displaying book information by implementing the `__str__()` special method.
199 implied HN points 20 Apr 23
  1. An iterable is an object you can loop through in Python.
  2. Iterables can be identified by whether they can be used in a for loop without errors.
  3. In Python, every object can be made iterable by defining special methods in a class.
179 implied HN points 17 May 23
  1. In the third year at Hogwarts School of Codecraft and Algorithmancy, students focus on defining methods in Python classes
  2. Each year at Hogwarts corresponds to learning different aspects of object-oriented programming, with Year 3 focusing on methods
  3. Methods in classes allow objects to have built-in functionality and perform actions within a program
179 implied HN points 07 May 23
  1. Python's functools.partial() allows you to pre-fill arguments in a function.
  2. You can use functools.partial() to modify functions and make them more efficient.
  3. The object returned by functools.partial() behaves like a function and has attributes like func, args, and keywords.