. Python 2.1 function attributes
Justin Sheehy
justin at iago.org
Mon Jan 29 01:46:15 EST 2001
"Tim Peters" <tim.one at home.com> writes:
> "print >>"
> would-be-more-impressed-by-the-damnation-of-people-who've-actually-
> tried-it-ly y'rs - tim
I've actually tried it, and I don't like it.
When 2.0 started to approach release time, I made a point of using the
new features in new code in cases where the program wouldn't have to
run anywhere other than my own workstation. (That restriction was
caused by the fact that it is non-trivial for me to get a new Python
version onto all of the machines that I care about.)
My thoughts on a few of the notable new features:
- list comprehensions
Very well done. I don't find myself using them very often yet, but
I approve of these both conceptually and in Python's implementation.
I suspect that once 2.0 becomes as ubiquitous as 1.5.x, I will
begin to use these more heavily. That might depend on whether
their speed improves. I'm not sure, since I haven't used them
enough yet to determine if that will be a bottleneck for me.
- augmented assignment
Overall, I am glad this made it in. Sometimes, it is more
convenient and more clear than (e.g.) a = a + b. I recognize the huge
value of augmented assignment in certain situations (such as large
matrices in Numeric). However, I think that there is another side
to this.
The varying-behavior-depending-on-mutability aspect of += (which is
necessary for it to be useful) is likely to cause some confusion.
Admittedly, the ones most confused will probably be the ones that
don't quickly grok Python's name, assignment and reference models.
The fact that += sometimes acts like = but sometimes acts
like a method call seems like a flaw to me. Since I can't think of
a better way to solve the problem, I'll shut up about it now.
- print >>
Ugly. Really ugly.
Perhaps I don't count, though, since I didn't use the print
statement very much before anyway. I tend to only use "print" either
for crude debugging or for simple scripts. For most output I use
fd.write() with heavy applciation of the %s format character.
I tried using the new print statement, though. I found that while
it made some code shorter, it also made it look (to my eyes) less
Pythonic. Using a series of special characters in order to save a few
lines of space seems more like something done by That Other P Language,
and less like something that meets with Python's usual simplicity
and explicitness.
I know it won't change now. I don't hate it enough to try to
demand that it be excised, in any case. But I also know that I
don't expect to use it in anything I write anytime soon.
damnation?-you-asked-for-it-you-got-it-ly y'rs
-Justin
More information about the Python-list
mailing list