The Interpreter Pattern: Defining a Language The Interpreter pattern is used to define a grammar for simple languages and implement an interpreter to process sentences in that language. It's ideal for domain-specific languages (DSLs), mathematical expressions, or simple configuration rules. How it Works: The grammar is defined using a class hierarchy where each rule or … Continue reading Python Literacy Continue 3
Author: Naixian Zhang
Python Literacy Continue 2
Metaclasses: The Class of a Class ✨ A metaclass is the entity that creates a class—it is literally the "class of a class." Metaclasses allow you to define rules or inject behavior into classes as they are being built. Rule Enforcement: Metaclasses are used to ensure rules on a class are followed (e.g., ensuring all … Continue reading Python Literacy Continue 2
Python Literacy Continue 1
This blog post summary covers several key object-oriented programming (OOP) and design principles, with a focus on Python implementation and idiom. Class Construction and Separation of Concerns Internal vs. External Data: When constructing a class, data passed as arguments from the user (like initial values) are external. Internal operational data, such as a running count … Continue reading Python Literacy Continue 1
Notes Summery on Python Literacy
In the age of AI, code literacy has become what mathematical literacy once was: the essential tool for expressing, testing, and sharing thought. Understanding how to structure code — not just make it run — is how modern scientists, engineers, and creators communicate ideas that scale beyond themselves. Python, being expressive and readable, is the … Continue reading Notes Summery on Python Literacy
Advanced Python Features
Summary: Top 18 Advanced Python Concepts #ConceptLocationWhy Important1Async Context Managerclient.py:55-78Resource lifecycle2Dataclass field()types.py:37Mutable defaults3post_inittypes.py:132Auto-validation4Enum(str, Enum)types.py:17JSON-serializable enums5Union (AB)client.py:366isinstance type guardsclient.py:144Type narrowing7Literal typestypes.py:84Exact value constraints8Callable/Awaitabletypes.py:90Async callback types9Private methods (_)client.py:198API encapsulation10Defensive copyclient.py:333Prevent mutation11Error-as-valueclient.py:141-192Railway-oriented design12@staticmethodengine.py:20Pure functions13dict.get()engine.py:84Safe access14perf_counter()client.py:139High-precision timing15Observer patternclient.py:198-239Hook system16Module structureinit.pySeparation of concerns17Relative importsclient.py:12Package portability18Builder patterntypes.py:104Flexible configuration One by one analysis: First Async Context Manager for example class CalculatorClient: def … Continue reading Advanced Python Features
Types
This post is to cover a comprehensive, intuitive set of advanced typing primitives that show up in modern Python (≥3.9). These types enable:- Type safety without runtime overhead- Better IDE autocomplete- Self-documenting APIs- Generic/reusable code To read below codes, need to know Type hints are ignored by Python’s interpreter — they exist only for static … Continue reading Types
Session Management
Session management in agentic workflows refers to how an AI agent (or system of agents) maintains context, state, and continuity across multiple interactions or steps in a task. In simpler terms, it’s how an agent “remembers” what’s going on — what’s been done, what’s being worked on, and what still needs to be done — … Continue reading Session Management
Claude Code Shine in Explaining How Developers Work
This is the best insight I’ve ever received, straight from Claude Code, addressing the questions I have about developing professional SDKs. RIGHT approach: Start at Level 0: def add(a, b): return a + b When you need it in 2 projects → Level 2 (class) When projects have different needs → Level 3 (config) When … Continue reading Claude Code Shine in Explaining How Developers Work
Use the Best Tool to Learn Two Agents
Anthropic has developed the ultimate coding agent, Claude Code, which stands out as the premier tool for learning about agents. My previous methods of reading documentation and source code are now vastly inferior and significantly less efficient than utilizing this powerful tool. Here is a demo on how it helps me learn two agents SDKs, … Continue reading Use the Best Tool to Learn Two Agents
A Practical Guide to Building Agents by OpenAI
This is the guide provided by OpenAI to help use agents SDK. Several key points cited in the following. First, write good prompts to configure, for example use advanced models such as o3-mini to write "“You are an expert in writing instructions for an LLM agent. Convert the following help center document into a clear … Continue reading A Practical Guide to Building Agents by OpenAI