• 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

Tag Archives: Python code

Bloom Filters in Python

19 Monday Aug 2024

Posted by Wyrd Smythe in CS101, Python

≈ 3 Comments

Tags

Bloom filter, computer programming, Python code, software design

I recently learned about Bloom filters (and was then able to fully understand the joke in this xkcd comic). While I don’t have a good application for them myself, I found them interesting enough to play around with a little.

Python uses them under the hood in a way that has some potential for other applications. In this post I’ll explain Bloom filter basics and go over some simple implementations.

Continue reading →

Simple Python Tricks #8

05 Monday Aug 2024

Posted by Wyrd Smythe in Python

≈ 4 Comments

Tags

format function, format method, format strings, Python code, Simple Tricks

Simple Tricks started late last year with a “project” post that may have been a misfire, though it’s possible I’ll do some other simple projects in the future (though my question is whether they’re really “simple tricks” — I’m not sure the first post in the series qualified).

Regardless, since then we’ve looked at Python comprehensions (see here and here), file handling techniques (see here and here), and function parameters (see here and here). This time we look at printing output with an emphasis on formatted output.

Continue reading →

Simple Python Tricks #7

22 Monday Jul 2024

Posted by Wyrd Smythe in Python

≈ 3 Comments

Tags

Python code, Simple Tricks

The previous post in this Simple Tricks series began an exploration into function parameters and arguments. (Parameters are what a function declares it takes. Arguments are values passed at runtime.)

We covered optional arguments with defaults and variable arity functions. We left off with variable arity keyword parameters and a synchronization problem.

Continue reading →

Simple Python Tricks #6

08 Monday Jul 2024

Posted by Wyrd Smythe in Python

≈ 4 Comments

Tags

Python code, Simple Tricks

The last two posts in this Simple Tricks series (Tricks #4 and Tricks #5) explored the basics of file handling. The two before that (Tricks #2 and Tricks #3) explored Python list comprehensions.

This time we’ll explore something extremely basic, passing parameters to functions. Python has interesting native capabilities that give programmers options in how they deal with function parameters.

Continue reading →

Simple Python Tricks #5

22 Saturday Jun 2024

Posted by Wyrd Smythe in Python

≈ 3 Comments

Tags

file system, Python code, Simple Tricks

Last time we looked at dealing with files in Python, looked into filename handling, and left off after creating a couple of base classes to support general file operations.

This time we’ll extend those classes into some useful file utility classes for handling data from different types of files (for instance, binary, plain text, line-oriented text, and any type of structured file).

Continue reading →

Simple Python Tricks #4

08 Saturday Jun 2024

Posted by Wyrd Smythe in Python

≈ 4 Comments

Tags

file system, Python code, Simple Tricks

The last two posts looked at Python list comprehensions. [See Simple Tricks #2 and Simple Tricks #3] This time we look at file handling, one of the most common tasks programmers deal with, especially with script languages such as Python.

Python’s native file object, created with the built in open function, is simple and easy, but here are some tricks that make file access even simpler and easier.

Continue reading →

Simple Python Tricks #3

30 Thursday May 2024

Posted by Wyrd Smythe in Python

≈ 5 Comments

Tags

list comprehensions, Python code, Simple Tricks

In the last post we looked at Python list comprehensions, an inline alternative to for-next loops. List comprehensions are a powerful technique for creating and processing lists.

In this post, we’ll look at more list comprehensions, including some real-life examples, and look at three other kinds of Python comprehensions: sets, dictionaries, and generators.

Continue reading →

Simple Python Tricks #2

21 Tuesday May 2024

Posted by Wyrd Smythe in Python

≈ 6 Comments

Tags

list comprehensions, Python code, Simple Tricks

Considering that it has been six months since the last post, my attempt to get a post flow going with “Simple Python Tricks” left something to be desired. Like success. Undaunted, I’m drawing from the well again.

This time to discuss Python comprehensions, a feature that is powerful and expressive, but which is rather unique to Python. Newcomers may not, at first, even realize they exist.

Continue reading →

Simple Python Tricks #1

18 Saturday Nov 2023

Posted by Wyrd Smythe in Python

≈ 3 Comments

Tags

Python code, Simple Tricks

While I love coding, it turns out I don’t enjoy blogging about it quite as much as I thought I would. But I’m not ready to toss in the towel yet, and to help develop more of a habit of posting here, I thought I’d try posting some really simple things.

These are simple tricks intended to help beginners dig deeper into coding with Python.

Continue reading →

Python Descriptors, part 2

18 Wednesday Oct 2023

Posted by Wyrd Smythe in Python

≈ 2 Comments

Tags

Python 101, Python code, Python descriptors, Python properties

Python has the useful notion of descriptor objects, which give object attributes control over how they are accessed. Descriptors enable calculated-on-the-fly attribute values and can prevent or control modification of data values.

The previous post covered the basics. In this post, I’ll dig deeper into Python descriptors with some more involved examples. This post assumes the basics covered in the previous post.

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