. Python 2.1 function attributes

Moshe Zadka moshez at zadka.site.co.il
Sat Jan 27 12:42:55 EST 2001


On Sat, 27 Jan 2001 12:12:07 -0500, Roy Katz <katz at Glue.umd.edu> wrote:

> Yeah, I was griping about the language going to hell and I meant it.  I
> don't mean to return to Python 1.3 days, but some things (notably
> print>>) contribute a fair share towards Perlization. 

I don't think so.

> Given Python's current "there's a right way to do it" motto, and
> its recent TMTOWTDIfication, perhaps a more fitting one would be
> "yeah, but so-and-so came up with a patch, and we couldn't resist, so we
> included it. So deal."

I disagree: in most cases, it was "well, there was a very ugly way to
do it, but so-and-so came up with a patch and a convincing argument.".

Examples:

Printing:
Standard output is a sinch:

print foo, bar

Does lots of things in an intuitive way (prints new lines and spaces,
calls str()). But when you decide to modify it to print to standard
error, or a log file it turns into either

sys.stderr(str(foo)+' '+str(bar)+'\n')

Or

sys.stdout = sys.stderr
try:
	print foo, bar
finally:
	sys.stdout = sys.__stdout__

Compared to both,

print >>sys.stderr foo, bar

Is obvious, simple and easy to understand.

List comprehensions:
You want to get values of a dictionary for a subset of the keys.

Both

map(lambda x,d=d: d[x], subset)

And

map(operator.getitem, [d]*len(subset), subset)

Are less obvious then

[d[x] for x in subset]

You may wonder why it all happened all of a sudden? For years, 
there was one-and-a-half people working on Python seriously who
could check in directly to the master CVS. Suddenly an explosion
of developers happened and there were many more man hours to invest
in Python.

> I call for boycotting print>>.  I expect one person, maybe less,
> to support me on that.  

Sadly, too many people here support you in that. Sadly, because it's
a feature that was added by people who write a *lot* of Python, and
wanted to make Python-writing more fun.

-- 
Moshe Zadka <sig at zadka.site.co.il>
This is a signature anti-virus. 
Please stop the spread of signature viruses!
Fingerprint: 4BD1 7705 EEC0 260A 7F21  4817 C7FC A636 46D0 1BD6




More information about the Python-list mailing list