Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python String Formatting

A structured guide to string formatting in Python, comparing f-strings and str.format() across their syntax, format specifiers, and practical use cases.

🎓 Part of my self-directed learning alongside the Telecommunications Technology Engineering degree at Universitat Politècnica de València (UPV).


📌 Overview

This repository documents the two main approaches to string formatting in Python. Each directory isolates a specific layer of the topic — syntax, format specifiers, and applied examples — so the progression from basic concept to practical usage is explicit and easy to follow.


🛠️ Modules Summary

Module Core Focus Concepts Implemented
🔤 F-Strings Syntax & Definition Literal string interpolation and embedded expressions.
🧩 str.format() Syntax & Definition Positional and named placeholders via the .format() method.
🎛️ Format Specifiers Formatting Mini-Language Alignment, padding, precision, percentages, scientific notation, hex, dates.
🚀 Examples Applied Practice Practical scenarios combining both methods with format specifiers.

🧠 Key Learnings & Architecture Evolution

  1. Separation of Concerns: Splitting "what a method is" (01-f-strings, 02-str-format) from "what it can do" (03-format-specifiers), so each layer can be learned independently.
  2. Format Specifier Mini-Language: Understanding the shared {:spec} grammar that both f-strings and .format() rely on internally.
  3. Method Equivalence: Recognizing that f-strings and .format() solve the same formatting problems, differing mainly in syntax and evaluation context.
  4. Applied Practice: Reinforcing theory with side-by-side examples (con_fstring.py / con_format.py) for each formatting case.

🚀 How to Run

Prerequisites

  • Python 3.6+ installed (f-strings require 3.6; the = debugging specifier requires 3.8+).

Execution

Explained in each of the folders README's.

About

This repository, teaches python learners to format their strings, explaining it from an engineering student point of view. Trying to explain it in a practical and easy way, as it seems to be a challenging thing to learn for the newest ones in python.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors