Beyond Indentation and Invisible Sigils

chromatic on 2007-09-26T19:38:27

Here are some prescriptions for writing Python code that other Python programmers will find more usable and readable than it might otherwise have been (i.e. code that "doesn't obviously suck").

— Titus Brown, Writing (Python) Code that Doesn't Suck, v2

Syntax doesn't give you readable code for free. Snarkiness aside, Titus's rules are pretty universal.


Running tests

jplindstrom on 2007-09-26T22:23:19

This one, while it doesn't strike me as a very perlish thing to do, we already have conventions and libraries in place to do this in a different way, seems like a very natural way to organize unit tests:

modules, when executed from the command line, should
either run tests or do nothing.
But, yes, 90% of the specifics and 100% of the concepts of that had nothing to do with Python.

Re:Running tests

Aristotle on 2007-09-27T09:56:01

All well-behaved Perl modules do nothing if you run them directly, so they already “run tests or do nothing”… :-)

Proof of Syntax and Readability

ziggy on 2007-09-27T03:41:51

Syntax doesn't give you readable code for free.

Hm. Let's test this out.

  • Scheme has uniform syntax.
  • Uniform syntax is trivial to learn, and easy to read.
  • Therefore, if uniform syntax leads to readable code, then Scheme expressions should all be very readable and easy to understand

Proof:

((call/cc call/cc) (call/cc call/cc))

Hm. I guess uniform syntax doesn't necessarily lead to readable code. :-)

Re:Proof of Syntax and Readability

chromatic on 2007-09-27T17:59:25

It's computers, so the analogy should involve cars, but "Just because I can diagram a sentence doesn't mean I can read Finnegan's Wake."