• 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: format method

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 #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 →

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