1. Think in Python data
5 min
Start with shapes
Before you write a Python tool, decide what your data looks like in memory.
Most small command-line tools use only a few shapes: strings, numbers, booleans, lists, and dictionaries. If you can model your data with these, your script becomes easier to read, test, and change.
One idea
Python tools are mostly data going through steps. Pick a clear shape for the data first, then write code that transforms it.
Use the right type
Use a string for one piece of text, like a name or email. Use an int or float for numbers you may calculate with. Use a boolean for yes/no state.
Use a list when you have many similar items. Use a dictionary when each item has named fields, like a row from a CSV or a response from an API.
Model a record
Imagine your tool checks student project ideas and creates a short review. One project can be a dictionary. Many projects can be a list of dictionaries.
This is close to how JSON and APIs usually look, so it will help in later lessons.
project = {
"team": "ByteBoys",
"college": "Pune Institute of Computer Technology",
"idea": "UPI expense splitter for hostel students",
"uses_ai": True,
"score": 7
}
projects = [
project,
{
"team": "NullPointers",
"college": "SRM Chennai",
"idea": "Resume feedback bot",
"uses_ai": True,
"score": 8
}
]
print(projects[0]["idea"])
print(projects[1]["score"])