• Home
  • About
    • About The Coder
    • Language List
  • Code Rules
    • #1: Clarity Trumps Everything
    • #2: Source Code is for Humans
    • #3: Don’t Ignore Warnings
    • #4: Comment As You Go
    • #5: Always Use Parentheses
    • #6: Always Define Literals
    • #7: Never Repeat Yourself
  • CS-101
  • Python-101
  • Simple Tricks
  • Guestbook

The Hard-Core Coder

~ I can't stop writing code!

The Hard-Core Coder

Author Archives: Wyrd Smythe

Rule #7: Never Repeat Yourself

30 Monday Jun 2025

Posted by Wyrd Smythe in CS101

≈ 1 Comment

Tags

code clarity, computer programming

In the previous post I semi-corrected a long-time oversight by revisiting the post The Thing About Constants and turning it into a Coding Rule, Rule #6. (I say “semi-corrected” because it really should have been Rule #3.)

In this post I semi-correct another oversight represented by the post The Synchronization Problem. It’s the other one that has been bugging me for a while because it should have been a rule (probably Rule #4). As they say, “Better late than never.”

Continue reading →

Rule #6: Always Define Literals

23 Monday Jun 2025

Posted by Wyrd Smythe in CS101

≈ 2 Comments

Tags

code clarity, computer programming, constants, defined values, global constants, literal values, readable code

It has been more than a few minutes since I posted a Coding Rule, so I thought it was high time I did. There are at least two things I’ve previously written about as important but didn’t elevate to Rules. Both have been bugging me; they should be rules. Today (and a week from now) I’m correcting that oversight.

To be honest, this Rule is so important, I’m not sure why I didn’t make it the third one. Rule #1 and Rule #2 are definitely more important, but the ones currently listed as #3 – #5 are not as important as today’s (they are very important, though).

Continue reading →

Cellular Automaton Redux

12 Monday May 2025

Posted by Wyrd Smythe in Fun, Python

≈ 2 Comments

Tags

cellular automaton, Python code

In the previous post [see Elementary Cellular Automaton], I presented an implementation of a 1D elementary cellular automaton. Unfortunately, the code turned out to be an example of leaping into an idea without carefully reading the background information.

Long story short, while the code works and generates images, it doesn’t generate the correct images for all 256 rules. In this post, I present improved code that does.

Continue reading →

Elementary Cellular Automaton

28 Monday Apr 2025

Posted by Wyrd Smythe in Fun, Python

≈ 3 Comments

Tags

cellular automaton, Python code

For quite some time, I’ve wanted to write some Python code to implement and elementary cellular automaton. In particular, I wanted to “investigate” (play around with) the famous Rule 110, which is known to be Turing complete.

Despite the name, this has nothing to do with cellphones. It’s a 1D variation on the well-known 2D Game of Life designed by British mathematician John Conway. [See the John Conway’s Life and Life With Class posts for Python versions]

Continue reading →

Simple Python Tricks #15

31 Monday Mar 2025

Posted by Wyrd Smythe in Python

≈ 2 Comments

Tags

format method, format strings, Python code, regular expressions, Simple Tricks, str.translate, upside down characters

The political situation in the USA has dampened my mood and crashed my interest in this Simple Tricks series, but in hope of getting at least one post out this month (and on the very last day, no less), I’m going to revisit two topics I’ve written about before.

Back in Issue #8 of this series, I wrote about formatted output (to screen or file), especially using format strings (“f-strings”) and the format function and built-in method. In this issue, I’ll revisit the latter for a more sophisticated example. I also have some goodies for the str.translate method.

Continue reading →

Simple Python Tricks #14

17 Monday Feb 2025

Posted by Wyrd Smythe in Python

≈ 1 Comment

Tags

comma sequence, Python code, Simple Tricks

This post was meant to be the final edition of Simple Tricks in 2024. My every-other-Monday schedule had it slotted for December 23rd. But I came down with a respiratory virus on the 22nd. The post wasn’t complete at that point, so I pushed publication to the following Monday, the 30th, but I was sick until well into the new year.

I ended up taking January off from the web (and computers in general), and it’s not until now that I’ve caught up with myself. In any event, I’m not sure how many more of these Simple Tricks posts I’ll do, but here’s one more.
Continue reading →

Simple Python Tricks #13

09 Monday Dec 2024

Posted by Wyrd Smythe in Python

≈ 1 Comment

Tags

Monty Hall problem, Python code, Simple Tricks, tail recursion

The last few posts in this Simple Tricks series were perhaps a bit less than simple, so this month, here at the end of the year, I’m going to take it easy and enjoy the season. (I hope you are doing so as well!)

I’ve put together a random grab bag of little bits and pieces of Python. Nothing too complicated. And in all honesty, probably nothing terribly interesting or that useful, either. But you may find some of the approaches helpful.

Continue reading →

Simple Python Tricks #12

25 Monday Nov 2024

Posted by Wyrd Smythe in Python

≈ 1 Comment

Tags

Python classes, Python code, Python descriptors, Python properties, Simple Tricks

The last two Simple Tricks posts looked at subclasses of built-in Python classes, in particular the tuple class, as well as the built-in class methods Python supports for any user-defined class. [See Simple Tricks #10 and Simple Tricks #11.]

This time I narrow the focus to real and virtual object attributes, the “x”, “y”, “z” elements of our vector objects. Python offers many ways to implement these, depending (as always) on what you want.

Continue reading →

Simple Python Tricks #11

11 Monday Nov 2024

Posted by Wyrd Smythe in Python

≈ 2 Comments

Tags

Python classes, Python code, Simple Tricks

Last time we looked at subclassing the Python built-in classes tuple, list, and dict with a focus on the built-in __new__ and __init__ methods (and never forget to include __str__ and/or __repr__ in your user-defined classes).

This time Simple Tricks explores many of the other built-in methods that help you create richly featured Python-aware objects. Specifically, we’ll focus on subclassing tuple to create (immutable) vector objects. A basic understanding of object-oriented programming is assumed.

Continue reading →

Simple Python Tricks #10

28 Monday Oct 2024

Posted by Wyrd Smythe in Python

≈ 4 Comments

Tags

Python classes, Python code, Simple Tricks, sub-class

Last time, Simple Tricks looked at some built-in Python functions. This time, we look at three built-in Python container classes, tuple, list, and dict, with a focus on designing useful sub-classes based on them.

We’ll explore the built-in __new__ and __init__ methods in detail along with some of the other built-in methods that help you to create rich new types. [The reader is assumed to be familiar with the basics of object-oriented programming.]

Continue reading →

← Older posts
Newer posts →
Follow The Hard-Core Coder on WordPress.com

The Posts

  • Python Tk Calculator App
  • Tk Windows in Python
  • Dual Numbers in Python
  • Python Decorators, more
  • Python Decorators, redux
  • Byte Multiplication Trick
  • Parsing Multipart Form Data
  • Simple Python Tricks #18
  • Simple Python Tricks #17
  • Simple Python Tricks #16

The Topics

  • Blog (4)
  • CS101 (37)
  • Fun (36)
  • Interesting (5)
  • Opinion (12)
  • Python (59)
  • Stories (15)

The Month

December 2025
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
293031  
« Nov    

The Past

Posts

RSS Feed

Comments

RSS Feed

The Main Blog

Visit Logos con carne

Lots of wyrds... with meat!

The Author

Wyrd Smythe

Wyrd Smythe

The canonical fool on the hill watching the sunset and the rotation of the planet and thinking what he imagines are large thoughts.

View Full Profile →

Create a website or blog at WordPress.com

  • Subscribe Subscribed
    • The Hard-Core Coder
    • Already have a WordPress.com account? Log in now.
    • The Hard-Core Coder
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar