gah! I hate the new string syntax
Sean 'Shaleh' Perry
shaleh at valinux.com
Fri Mar 2 17:54:06 CET 2001
> 3. I *like* string methods, even .join(). I am aware that this puts me in a
> very small minority on comp.lang.python. But I would maintain that
> ";".join(...) only seems odd to you because you see it as the result of a
> strained migration from string.join(..., ";"), instead of seeing it with
> fresh eyes. However, I may add a footnote explaining the old style
> string.join, if only because new programmers will eventually come across old
> code that uses it.
if I were learning python today, I would still hate code like the above.
Turning a string literal (";") suddenly into a string object and then using its
methods is not an easy read. While trying to scan that line, my eye wants to
read the list comprehension (which is a nice feature, if compact). Then I see
the join function and it takes a moment to realize it belongs to the semicolon.
The other problem I have with this is I know too many languages. I am forced
to deal with quite a bit of perl and I actually read your book immediately
after a week's worth of working on some really evil perl code that was dumped
in my lap. SO what do I see?
";" . join() # in perl, this means concat ";" with the result of join()
Yes, I know this is an issue you learn to deal with. However, the nice, pretty
string module at least makes python look like python.
Mark, I like a lot of what I read in your book. The apihelper is a nifty idea
(if only it worked on the re module )-:). However, the coding style and
decisions seem counter to the python way. But maybe that is just me and my
hyper sensitivity to hard to read code after way too many lines of perl.
More information about the Python-list