PyConMY 2025

PyConMY 2025

Demystifying the term Pythonic
2025-11-02 , Hall 1

"That's not very Pythonic" - we've all heard this in code reviews, but what does it actually mean?

This talk cuts through the subjective confusion around "Pythonic" to provide a concrete, actionable definition based on Python's data model. Through my own journey of misconceptions - from obsessing over one-liners to avoiding classes - we'll discover that truly Pythonic code aligns with Python's own design philosophy by embracing the Python data model that make custom objects behave like native Python objects. Attendees will leave with practical techniques to write code that doesn't fight the framework but embraces it.


The term "Pythonic" is probably one of the most overused and poorly defined concepts in the Python community. From code reviews to Stack Overflow discussions, developers throw around this term without providing clear, actionable guidance. This talk addresses this problem head-on by providing a concrete definition rooted in Python's actual design philosophy.

Every Python developer has encountered vague feedback like "make it more Pythonic" without understanding what specific changes are needed. This leads to confusion, inconsistent code standards, and developers second-guessing their implementations. Unlike other programming languages that have rigid conventions, Python's flexibility has created a vacuum filled with subjective opinions about what constitutes "good" Python code.

The presentation follows my personal evolution from common misconceptions to clarity. I'll share real examples of code I once considered "Pythonic":

  • Complex one-liner list comprehensions that sacrificed readability for brevity
  • Overuse of lambda functions to appear "functional"
  • Avoiding classes entirely because "functional programming is the Pythonic way"
  • Focusing solely on PEP 8 compliance while ignoring deeper design principles
  • Adopting the latest Python features without understanding their proper use cases

The core revelation comes from Luciano Ramalho's insight in "Fluent Python": Pythonic code follows Python's data model. Unlike languages like Go that don't allow extending core functionality, Python's data model provides protocols that let our custom objects integrate seamlessly with built-in functions and operators.
Through code demonstrations, I'll transform a basic class step-by-step:

  • Start with verbose getter/setter methods (Java-style)
  • Implement len and getitem to work with len() and iteration
  • Add contains to support the in operator
  • Implement str and repr for better debugging
  • Show context manager protocol with enter and exit

Each step demonstrates how following Python's protocols makes our code feel native rather than foreign.

Beyond individual techniques, I'll provide a framework teams can use to evaluate code:

  • Does this object follow Python's conventions for similar built-in types?
  • Are we implementing the appropriate dunder methods for our object's behavior?
  • Does our code integrate naturally with Python's ecosystem (iteration, context management, etc.)?
  • Are we fighting the language or working with it?

Attendees will leave with:

  • A clear, objective definition of "Pythonic" based on the data model
  • Specific protocols to implement in their own classes
  • A mental framework for evaluating code quality beyond style guides
  • A better appreciation of Python's design philosophy

This talk transforms "Pythonic" from a subjective opinion into an objective standard that teams can apply consistently across their codebases.

Target Audience: Intermediate Python developers with 1+ years of experience.

I am a software engineer currently working as a Lead Backend Engineer at Doist Inc, creators of Todoist and Twist. I've been working with Python in my day job for over 7 years now. I have a Bachelor's in CSE from Bangladesh University of Engineering & Technology.

I love Python and have had the privilege of working with some industry veterans in the Python community like Lennart Regebro and Daniel & Audrey Greenfeld. I was also a tech reviewer for Two Scoops of Django's latest edition.