// I need to

ModernizeUpgrade without breaking it RescueFix what someone else started Build NewTurn an idea into a product Reach More PeopleGet found, get used, include everyone

// Company

Case StudiesExpertiseAbout + CareersResourcesContact Book a call →
≡articleBuild New

Who is Alex Martelli?

If you google Python problems, you've met Alex Martelli on Stack Overflow. A tour of his clearest answers and why they're worth reading.

Art+Logic May 24, 20133 min read

From the Art+Logic archive · written in 2013. The tools may have moved on; the thinking still holds.

or: “5569 Things You Can Learn About Python From This Guy On The Internet”

I like programming in Python, and sometimes (not more than a few times an hour) I get stuck and google my problem. When I do this it is very common to have Stack Overflow be the most useful result, and then it’s very common for some guy called Alex Martelli to have answered the question clearly and provided deeper insight into the whole area. Some examples:

What’s the difference between __repr__ and __str__ ?

Queues are awesome

Why properties?

Here’s his profile on Stack Overflow.

Here’s all of his answers.

It doesn’t take long following the links in his profile to find out that he wrote Python in a Nutshell and more recently cowrote Python Cookbook, works at Google, and had the Zen of Python read at his wedding. So well enough credentialed to tell us how to write Python I would say.

More answers:

Explanation that there is no such thing as compiled vs interpreted and what do you mean by ‘python’ anyway?

Wherein he says that using True and False as list indices is a perfectly reasonable thing to do:

def bool_to_str(value):
    """value should be a bool"""
    return ['No', 'Yes'][value]

and GVR chimes in to agree with him.

Where he explains that he’d choose a loop to write a list to a file, because why use the memory to materialize the whole list of strings?

Wherein he dispenses some advice from experience.

Queues are great (again), threading is most valuable for IO bound operations.

Windows is a weird OS.

You should know the standard library, especially itertools, collections.

There’s something called contextlib?

Helps you with your AI homework.

Shows you a factory pattern.

And there are many many more answers, more than 5000 in total. But wait! There are more people with things to teach us.

Like Martijn Pieters who is a Plone framework teams member and Plone Metrics Person of the Year 2012. He will:

Show you rsplit.

Show you dis and how to find the source for any bit of python.

Apparently there’s a psutil library? That looks very handy.

Or Greg Hewgill:

Talks about absolute and relative imports.

Or Ignacio Vazquez-Abrams:

A not at all incomprehensible one liner for generating random strings including upper case and digits. (Did you know there was a string module? I guess properly learning the standard library is moving to the top of my todo list.)

There are a lot of tools included in the python standard library.

I like reading Stack Overflow answers because I find the question and answer format puts information in my head with less friction than reading the docs. Something about there being a problem solved succinctly lets my brain engage with the information well. It’s also a less formal form than documentation so you get fun asides; example code snippets; backtracking and correcting mistakes. It’s much more human which makes it feel more accessible. It is broad, rather than deep, and the random seeming nature leads you to discovery, and also patterns across topics (learning the standard library more deeply seems like a good thing.)

And it goes perhaps without saying that learning more than you already know about your programming languages is a good thing. To think that you know it all, or you know enough to do what you do is a trap leading to stagnation. Becoming expert at your tools is a time saving, efficiency promoting endeavor, especially when writing code. Better understanding leads to better thought processes leads to better design leads to better software. Which snowballs into less maintenance, faster, more efficient programs, and a better world for everyone to live in.

Alex and others have given us something really amazing and it would be a shame to miss it. Happy reading.

keep going

More to explore in Build New.

All Build New resources →
let's talk

Got a problem like this one?

Tell us what's stuck. A real person replies within one business day.

Talk to our team →

Talk to people who know software, not a sales script.

Your first call is with Aja, our VP of Sales. He'll help make sure you're solving the right problem. Here's what you'll cover together:

  1. What you're trying to accomplish

    The business goal first, then the technology.

  2. Possible approaches

    And the tradeoffs of each, in plain language.

  3. Risks you may not have considered

    Technical and business, before they cost you.

  4. Whether AI changes the math

    What's practical, and what's just hype for your project.

  5. Sensible next steps

    Even if the right next step is not us.

book-a-call.ics

Loading the scheduler…

Open the booking page →

Some problems are easier to explain in writing. Send us a few lines about what you're working on, and we'll reply within one business day. Helpful to include:

  1. What the software does, or should do
  2. What's stuck, or what's worrying you
  3. Any deadline or budget you have in mind
note.md

Loading the form…