TIMTOWTDI

@thomasguest

wordaligned.org

@clinithinkwales

TDF-G-CDF

🚲

There is more than one way to do it

’Tsall good

Perl, the first postmodern computer language — Larry Wall, 1999

TSBO-APOO-OWTDI

ZOP

“The Python Way” — Tim Peters, 1999

Zen of Python

  1. There should be one—and preferably only one—obvious way to do it.
  2. Although that way may not be obvious at first unless you're Dutch.

TIMTOP

There is more than one Python

Python 2

Python 3

PyPy

Jupyter

TIMTOWTI

There is more than one way to iterate
>>> squares = [] >>> for x in range(42): ... squares.append(x*x)
>>> squares = [x*x for x in range(42)]
>>> squares = (x*x for x in range(42))
>>> squares = map(mul, *tee(count())

TIMTOPOM

There is more than one Program Options module

getopt

optparse

argparse

etc. etc. etc...

Users who are unfamiliar with the C getopt() function or who would like to write less code and get better help and error messages should consider using the argparse module instead.

docs.python.org

TIMTOUTF

There is more than one Unit Testing framework

unittest

doctest

pytest

etc...

The unittest unit testing framework was originally inspired by JUnit and has a similar flavor as major unit testing frameworks in other languages.

docs.python.org

TIMTOWOFS

There is more than one way of formatting strings

"double quotes"

'single quotes'

"""triple quotes"""

r'\raw'

R"""\ROAR!!!"""

who, what = 'Thomas', 'noodles'
'%s likes %s' % (who, what)
t = string.Template('$who likes $what') t.substitute(locals())
'{} likes {}'.format(who, what)
f'{who} likes {what}'

Don’t Do It This Way

>>> Ω = 'There is more than one way to do it'
>>> F'''\
{   """"""
.   join(ω[0]
.   upper() 
    for ω in Ω.split())
}\
'''
'TIMTOWTDI'

The Zen of Python, by Tim Peters

  • Beautiful is better than ugly.
  • Explicit is better than implicit.
  • Simple is better than complex.
  • Complex is better than complicated.
  • Flat is better than nested.
  • Sparse is better than dense.
  • Readability counts.
  • Special cases aren’t special enough to break the rules.
  • Although practicality beats purity.
  • Errors should never pass silently.
  • Unless explicitly silenced.
  • In the face of ambiguity, refuse the temptation to guess.
  • There should be one—and preferably only one—obvious way to do it.
  • Although that way may not be obvious at first unless you're Dutch.
  • Now is better than never.
  • Although never is often better than right now.
  • If the implementation is hard to explain, it’s a bad idea.
  • If the implementation is easy to explain, it may be a good idea.
  • Namespaces are one honking great idea—let's do more of those!

The Taming of the Camel

Slide from Larry Wall talk on Perl5

— Larry Wall, 1994

Now that PEP 572 is done, I don’t ever want to have to fight so hard for a PEP and find that so many people despise my decisions.

Guido van Rossum, Transfer of Power

How many times have we heard the mantra that a program should do one thing and do it well?

Perl, the first postmodern computer language — Larry Wall, 1999

If all you have is a hammer, everything starts to look like a nail.

If all you have is duct tape, everything starts to look like a duct.

When’s the last time you used duct tape on a duct?

THANKYOU

@thomasguest

wordaligned.org