• Home
  • About
    • About The Coder
    • Language List
  • The Rules
    • Rule #1: Clarity Trumps Everything
    • Rule #2: Source Code is for Humans
    • Rule #3: Don’t Ignore Warnings
    • Rule #4: Comment As You Go!
    • Rule #5: Always Use Parentheses
  • CS-101
  • Python-101
  • Guestbook

The Hard-Core Coder

~ I can't stop writing code!

The Hard-Core Coder

Author Archives: Wyrd Smythe

Python String Translate

13 Thursday Oct 2022

Posted by Wyrd Smythe in Python

≈ 1 Comment

Tags

Python 101, Python code

Python str instances have many useful methods. I use strip, split, startswith, and others, quite a lot, for instance. One method I haven’t had reason to use so far is translate. It takes a dictionary argument and uses it to map the existing string to a new string.

It’s flexible and useful, so it’s worth knowing how to use.

Continue reading →

The Last Bug

26 Friday Aug 2022

Posted by Wyrd Smythe in Fun

≈ 2 Comments

Tags

computer humor, funny poetry, humor, old time stuff, poetry

Recently I posted an oldie from the last century. Here’s another from the deep time layers of my file system. It’s a poetic parable any programmer can relate to.

Think of it as the programmer’s version of Sisyphus.

Continue reading →

Regular Expressions

23 Thursday Jun 2022

Posted by Wyrd Smythe in CS101

≈ 1 Comment

Tags

computer languages, computer programmers, real programmers, strings

There are many general skills a programmer should have to be effective and valuable. Some are very general — for instance, the ability to learn and to think abstractly — but some are more specific — various tools and tricks of skilled programming.

Among those tools are several non-programming languages all programmers should know. Those include HTML, XML, SQL, and an old one whose name doesn’t end with “L” — Regular Expressions (aka REs, aka RegEx or RegExp).

Continue reading →

Bits Bytes Chips Clocks

03 Thursday Mar 2022

Posted by Wyrd Smythe in Fun

≈ 4 Comments

Tags

computer humor, funny poetry, humor, old time stuff, poetry

It’s been a while since I posted here, many balls in the fire and irons in the air, so I thought I’d dig into my archives for an oldie, albeit one more of tin than of gold.

This one comes from a 1995 email from a co-worker who was forwarding something cute she’d found in a Delphi Forum.

Continue reading →

Loving the Lambda

15 Saturday Jan 2022

Posted by Wyrd Smythe in Python

≈ 3 Comments

Tags

computer code, program, Python 101, Python code, Python lambda

One part of Python I especially appreciate is lambda functions. While I’ve never pursued functional programming, I do like many things about it, particularly the notion of functions as native data objects. Programming with functional objects opens new vistas. Most languages handle it one way or another, but languages make it natural.

Python’s lambda is such a facility, and I use it often. This week I finally got around to writing a lambda function I’ve been meaning to for a long time, and it’s my new favorite. I thought I’d share it along with some of my other “one-liners”…

Continue reading →

Failure Tales

10 Monday Jan 2022

Posted by Wyrd Smythe in Stories

≈ 1 Comment

Tags

Fortran, Lotus Notes

In job interviews they sometimes ask about a time you failed. It’s meant as a probe into your self-image and reactions. How you react when challenged; what do you do about obstacles. I suspect anyone whose career revolves around solving problems has a few stories about “the one that got away.”

A recent online conversation inadvertently reminded me of all three that stand out in my history. I made a note to write a post about them. The new year seems like a good time for a trip down memory lane…

Continue reading →

Naming Things (redux)

27 Monday Dec 2021

Posted by Wyrd Smythe in CS101

≈ 1 Comment

Tags

code clarity, computer code, computer programming, readable code

The first article (long, long ago) about naming things only scratched the surface. Even with company and language guidelines (or other rules) to help, with so many things to name it’s easy to lose control. Even now, after 44 years of writing code, I still sometimes find myself staring at the screen trying to think of what to name some object.

It’s understandable; there are a lot of things to think about when it comes to a name.

Continue reading →

Calculating Entropy (in Python)

21 Tuesday Dec 2021

Posted by Wyrd Smythe in Python

≈ 2 Comments

Tags

entropy, Python code, Shannon entropy

I’ve been playing with calculating the entropy of a toy system used to illustrate the connection between “disorder” and entropy. (See Entropy 101 and Entropy 102.) I needed to calculate the minimum number of moves required to sort a disordered collection, but that turns out to be an NP problem (no doubt related to Traveling Salesman).

The illustration bridges Boltzmann and Shannon entropy, which got me playing around with the latter, and that led to some practical results. This article describes the code I used mainly as an excuse to try embedding my own colorized source code blocks.

Continue reading →

Building a Turing Machine

10 Friday Dec 2021

Posted by Wyrd Smythe in Fun, Python

≈ 1 Comment

Tags

modeling, Python code, simulation, Turing Machine

I’m not sure how I got to thinking about Turing Machines (TMs). I was going through some files recently and spent some time looking at busy-beaver.c (from 2017 according to the file date). It contains an implementation of a TM. But something else got me speculating about my own implementation; I just don’t recall what.

I decided to actually write it when it occurred to me that I could use a Python generator to implement the Turing Machine tape. Sadly, I didn’t think of it in time for the trilogy I just published about Python generators (part 1, part 2, part 3).

Continue reading →

Python Tokenize

03 Friday Dec 2021

Posted by Wyrd Smythe in Python

≈ 1 Comment

Tags

HTML, Python 101, Python code

Recently I thought to myself, “Hey self,… Although I’ve never looked into them, I know Python has tools for parsing Python code. I wonder if they might make generating syntax-highlighted HTML pages of Python scripts pretty easy?”

I found the help page for the tokenize module, and the introduction says it’s “useful for implementing ‘pretty-printers,’ including colorizers for on-screen displays.” That sounds like a strong yes.

Continue reading →

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

The Posts

  • Python String Translate
  • The Last Bug
  • Regular Expressions
  • Bits Bytes Chips Clocks
  • Loving the Lambda
  • Failure Tales
  • Naming Things (redux)
  • Calculating Entropy (in Python)
  • Building a Turing Machine
  • Python Tokenize

The Topics

  • Blog (4)
  • CS101 (35)
  • Fun (27)
  • Interesting (1)
  • Opinion (12)
  • Python (24)
  • Stories (15)

The Month

March 2023
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Oct    

The Past

Posts

RSS Feed

Comments

RSS Feed

Enter your email address to follow The Hard-Core Coder and get email when there is a new post.

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

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