Whython – Python For People Who Hate Whitespace

Whython : Whitespace Haters Python



Clearly Confusing (standard 3.x):

for ii in range(10):
    print("which is %s" % (['even','odd'][ii % 2]))


for ii in range(10) {
    print("which is %s" % (['even','odd'][ii % 2]));

Maximum Enterprise Whythonic:

for ii in range(10) { print(ii); print("which is %s" % (['even','odd'][ii % 2])); }

How about some Scheme with your Python?

defun myfun():  return 1
assert myfun() == 1

Or add some Ruby shine?

def myfun() BEGIN return 1; END
assert myfun() == 1

Why Whython?

  • Less Whitespace, More Enterprise
  • It’s not a real language without braces and semi colons
  • Whitespace delimited is like so restrictive, man!
  • Python sucks for code golf
  • Finally, a Python for everyone who can’t decide between tab and space
  • Possibly (as in the mathematical sense – a small non-zero probability)
    useful for doing command line one liners in python
  • Help determine how bad a PEP/developement idea needs to be before
    someone gets kickbanned from #python-dev.

More seriously

  • reading the Dragon Book [Aho86] gives a person dangerous ideas
  • good excuse to deep dive into the python interpreter source code and the AST, dis modules
  • finally wanted to learn GDB and python -d debug mode
  • humoring trolls is fun
  • for education, the whitespace thing really can cause problems. When
    copying code out of books into IDLE or IPython, there are corner cases when
    it terminates blocks “too early”, confusing new learners.
  • preparation for the “Python Spring Cleaning” project, to see how hard it is
    to get and modify source, write a PEP, raise bug ideas, talk in irc, etc.
  • since this is unlikely to ever be adopted by Python (I hope!), it will
    remain a useful exercise, unlike othe “bugs” which get fixed once and for

Want It? (Download and Install)

Are you sure you can handle this level of awesome? Okay! Download and install:


## Get the source!
$ hg clone https://gregglind@bitbucket.org/gregglind/python-whython3k/
    # or if you haven't jumped on the `Mercurial <http://mercurial.selenic.com/wiki/Tutorial>`_  bandwagon
    # then:  wget http://bitbucket.org/gregglind/python-whython3k/get/79a2c77fe3e1.zip and unzip it!
$ cd python-whython3k
$ configure  # go make a pot of tea
$ make       # go watch an episode of the `IT Crowd <http://www.netflix.com/WiMovie/The_IT_Crowd_Series_1/70113774>`_
$ ./whython  # beautiful failure begins


  • only simple_stmt are really usable in this way. That means that
    blocks (functions, if, else, etc.) can’t be nested inside a braced block.

Thanks to

  • The Authors of PEP 306
  • GVR, Martin v. Loewis (my umlaut is misbehaving!), Georg Brandl, Greg Ewing, Jeremy Hylton and others on the
    Python-Dev mailing list
  • Fred Drake, for responding to my crazy and incoherent email
  • gutworth, merwok, __ap__ and others in #python-dev


[Aho86] Alfred V. Aho, Ravi Sethi, Jeffrey D. Ullman.
Compilers: Principles, Techniques, and Tools,

25 Comments on “Whython – Python For People Who Hate Whitespace”

  1. dixinshell says:


  2. Chinny says:

    I think static typing and pointers would be excellent additions.

  3. Boris says:

    This is actually already included in Python 2.6:

    from __future__ import braces

  4. Dony Borris says:

    Remove the garbage collector. It sucks man! We are all adults here! We can clean our own shit!

  5. Bill Nutterworth says:

    Templates would be a good addition I think.

  6. Could you please add typed collection too, please? I can’t stand those lists with changing inner types. You could call these something along the lines of “AbstractStaticTypeCollections”, that would be so great !

  7. Did you create this based off CPython?
    I thought PyPy was designed with this kind of hacks in mind.

    i don’t dare to run it, in fear of having the current date written all over my screen.

  8. It seem to be a April Fools day… πŸ˜‰

  9. David says:

    I’d rather have an “end” syntax. Maybe even using variants, like “fi” instead of “end if” and “wend” instead of “end while”.

    This code would rock:

    while 1:
    if something: do_this() else do_something_else fi

  10. Mark says:

    This is an April Fool’s joke, right?

  11. writeonly says:

    Mark, you can look over the diffs from the python py3k tip yourself (it’s in Hg on bitbucket) and verify whether it is a joke easily enough.

  12. […] Whython by Matthias Derer on April 2nd, 2010 It’s not a real language without braces and semi colons via writeonly.wordpress.com […]

  13. […] Whython – Python For People Who Hate Whitespace Whython : Whitespace Haters Python […]

  14. boulabiar says:

    Whitespaces are a feature of python.
    They sould NOT be removed or bothered by another syntax.

    Python should keep only 1 syntax, this really a bad thing to remove or add this thing.
    Keep in mind that python code with whitespaces still readable and oblige people to write good code !

  15. thank you , realy you are helpfull .


  16. I thought this was some kind of April fools joke until I tried it. Thanks, I’ve just installed it and it worked like a dream.

    Thanks again.

  17. onpon4 says:

    HAH! This is absolutely HILARIOUS!!!! xD

    Um… this is a joke… right? I mean, I know it’s real, but you didn’t really intend for it to be used, did you?

  18. mr J says:

    i so wish it was true. I tried to like “indent is flow” but find it hard to read when longer than a few pages. Since py-devs always seems so elitist, i assume this is just a sad joke.

  19. point says:

    I guess people just hate Python because they can’t use their shitty K&R bracing.

  20. […] @hek2mgl writeonly.wordpress.com/2010/04/01/… […]

  21. people that want to feel cool with nothing cool to contribute….

  22. Fajeth says:

    You took one of the greatest features in Python, removed it and now you want approval? Denied. Seriously that’s not even a question of taste. How could anyone find a code block ending with approximately an quadrillion braces easy to read? And yes, it happens more often than anyone would be willing to admit that you’re staring at your screen with growing hate and disbelieve because it just won’t work. And after a few hours of searching for the missing brace you either crash your machine or delete the fucking code and start over… Slightly exaggerating here. Anyway, point is braces objectively contribute NOTHING to the readability of code. If you think so you’re just fooling yourself. In fact you can’t read code in general. #Ihatebraces

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s