[TUHS] [TULSA] Re: python

Phil Budne phil at ultimate.com
Fri Aug 4 02:57:31 AEST 2023

I come not to praise Python...

I picked up Python (v1) in the early 'aughts as a more readable
alternative to Perl and Ruby (non-alphanumerical variable names are a
non-starter for me).

I agree that using indentation alone to determine block structure was
an interesting thought experiment, but TERRIBLE in practice (you might
as well throw away any editing buffer where the phone rang after you
cut and paste, but before re-indenting code), BUT it does prevent (in
a rather fascist way) formatting abominations like the C code in
procmail and SimH.

Python continues to evolve, so it's a moving target, and the argument
that there is ONE RIGHT WAY(TM) to do anything is not only long dead,
but now deeply putrid (much as with the multiple doublings in the size
of C++ and later C++ + STL books).

I used to regard the Python2/Python3 world breakage as a fiasco, but
considering how quickly the language is mutating, perhaps is was a
good fiasco if it lowered the mutation rate for number of years.

On the subject of "no printf", there is not one, not two, but THREE
ways to format strings, easily compounded with print:

	print("%s %s" % ("hello", "world"))
	print("{1} {two}".format("hello", two="world"))
	print(f"{greeting} {populace}")

I'm pretty sure the last method (which initially made me vomit, due to
violating my hardwired ideas about complicating the lexer, as if it
can even be thought of as a separate layer), BUT I Seem To Recall that
it allows a class to implement a formatting method, which may (or may
not) work for complex numbers.

Type "hinting" has been mentioned: again, it's almost like a whole new
version of the language.  You need to pick a type checker, and likely
turn up the knobs to achieve any actual safety, and then deal with the
fact that not all packages supply hints out of the box.  It kind of
offers the desert-topping/floor-wax dichotomy: You can easily/quickly
write small programs with dynamic typing for quick one-offs, AND write
better armored code for libraries & production code.

On tabs vs spaces: Python3 forbids mixing them.  Again, fascist, but
"it's for your own good".

So yes, Python sucks, but I continue using it, and unlike sendmail
(which I continue to run, as I have a 200+ line .mc file it would take
me at LEAST a week to replicate the effects of in another MTA), I
don't tell people Python is unsuitable at any speed.

I'd probably happily write Go or Rust, given a situation (existing
project/program) where its use was inevitable, and I DO have a program
I think is a good candidate for rewriting in Go, but on the whole,
it's a useful tool for many kinds of programmers, and in many
situations, which I think is somewhat remarkable.

More information about the TUHS mailing list