Your Agents Crave State
Every ai app hits the same wall: the agent needs to remember something, store something, try something. Ghost is postgres built for that. Spin one up per agent. Fork it. Throw it away. Pay nothing when it sits idle.

Strings show up in every Python program you'll ever write. You need them for a variety of reasons:
Printing items to the console/output
Writing data to files (CSV, JSON, etc)
Constructing input for an LLM prompt, API request, or SQL query
Before getting to f-strings, let’s ground ourselves with what a string is: it’s Python’s built in type for text data. You can index and slice it like a sequence:
string = "Hello, world!"
print(string[0]) # "H"
print(string[:5]) # "Hello"» Digging a bit deeper, A string is a sequence of Unicode code points. CPython stores them in 1, 2, or 4 bytes per code point depending on the largest one in the string - see PEP 393 if you want the details.
Formatting a string using the f-string
An f-string (“formatted string literal”) is a string prefixed with f that lets you embed variables and expressions directly inside curly braces. Python evaluates whatever is in these braces at runtime and drops the result into a string:
name = "Brandon"
newsletter = "Python Snacks"
print(f"{name} writes the {newsletter} newsletter!")
# Brandon writes the Python Snacks newsleter!You can also call methods or do math inside the braces; anything that returns a value works:
print(f"Author's name: {name.upper()}")
# Author's name: BRANDON
print(f"The summation of 4 and 2 is: {4+2}")
# The summation of 4 and 2 is 6Why f-strings became the standard
Before PEP-498 introduced f-strings in Python 3.6, you had two options. The % operator (a relic from C) and str.format():
name = "Brandon"
"Hello, %s" % name
"Hello, {name}".format(name="Brandon")Both conventions still work; you'll see them in older codebases. But neither is what you should reach for in new code, for three reasons:
f-strings are easier to read. The variable sits where it appears in the final string. With
format(), you have to scan to the end of the line to find what each placeholder maps to.They evaluate expressions in line. You don’t have to compute a value just to add it into the string.
They’re faster. Digging one layer deeper, f-strings get compiled to dedicated bytecode, so they typically beat
.format()and%in benchmarks.
Formatting specs for f-strings
The syntax {value:spec} controls how the value renders. It’s bet to show by example:
pi = 3.14159265
print(f"{pi:.2f}") # 3.14
print(f"{pi:10.2f}") # " 3.14"
print(f"{pi:<10.2f}") # "3.14 "
print(f"{1234567:,}") # 1,234,567
print(f"{0.85:.1%}") # 85.0%You can also pad and align without using .zfill() and .ljust() :
print(f"{'hi':-<10}") # "hi--------"
print(f"{'hi':-^10}") # "----hi----"
print(f"{42:05}") # "00042"» For the full format spec mini-language, see the Python Docs.
Python 3.8 also added a debugging shortcut — putting = after a variable prints both its name and value:
name = "Brandon"
newsletter = "Python Snacks"
print(f"{name=} {newsletter=}")
# name='Brandon' newsletter='Python Snacks'One place to not use f-strings
f-strings are fantastic and should be used everywhere, except in logging if you’re using structlog:
import structlog
logger = structlog.get_logger()
# Don't do this
logger.info(f"Processing user {user_id}")
# Do this instead
logger.info("Processing user", uid = user_id)This is because it goes against the purpose of structlog to begin with: keeping data and messages separate.
Happy coding!
📧 Join the Python Snacks Newsletter! 🐍
Want even more Python-related content that’s useful? Here’s 3 reasons why you should subscribe the Python Snacks newsletter:
Get Ahead in Python with bite-sized Python tips and tricks delivered straight to your inbox, like the one above.
Exclusive Subscriber Perks: Receive a curated selection of up to 6 high-impact Python resources, tips, and exclusive insights with each email.
Get Smarter with Python in under 5 minutes. Your next Python breakthrough could just an email away.
You can unsubscribe at any time.
Interested in starting a newsletter or a blog?
Do you have a wealth of knowledge and insights to share with the world? Starting your own newsletter or blog is an excellent way to establish yourself as an authority in your field, connect with a like-minded community, and open up new opportunities.
If TikTok, Twitter, Facebook, or other social media platforms were to get banned, you’d lose all your followers. This is why you should start a newsletter: you own your audience.
This article may contain affiliate links. Affiliate links come at no cost to you and support the costs of this blog. Should you purchase a product/service from an affiliate link, it will come at no additional cost to you.


