[Python-Dev] extended print statement, uPre-PEP

Paul Prescod paul@prescod.net
Sun, 23 Jul 2000 22:41:39 -0500


"Barry A. Warsaw" wrote:
> 
> No we're not!  From token.h:
> 
> #define RIGHTSHIFT      35

Okay, okay, you're inventing a new semantic for an existing token.

> Where would people look to use >> in this sense elsewhere?

You've got me.

Maybe nowhere. 

Maybe they'll just ask why >> is a binary operator except in print.
Maybe they'll see

a=j>>k

and think it has something to do with string printing. That's reasonable
if you don't have the C-family background.

Maybe they just look back after six months and say: "Why the hell did I
learn that >> hack if it is never going to be used anywhere else in the
language?" 

Maybe they'll just be sitting in the front row of my Python class and
say: "that looks like somewhat of a hack and it reminds me of one of the
ugliest features of C++" and I won't have any answer except to say: "yes
its a hack, but believe me Python isn't really a hacky language...there
are just a few."

We all have different design aesthetics. I would rather see a hundred
clean features added to Python's syntax rather than one hack. You'll
recall that when you announced the addition of string methods I told you
that you had cleaned up one of my two big Python embarrassments. print
is the other.

Renumbering:

>     1 no requirement for parens
>     2 newline by default
>     3 easy string coercion 
>     4 easy string interpolation
>     5 less thinking about whitespace
> 
> Don't these things mostly crop up in printing, in one form or
> another.  I can imagine you might want to use something like #4 or
> #5 when, e.g. building a string to be used as a regex, but in that
> case, you already have #4 and #5, and probably don't want #2.  (We
> won't even touch #1 in that context :).

I don't follow.

Consider: I'm building up a string to be used to search my phones
database. 

(Prescod, Paul): phone=555-1211, fax=555-2121

Don't I want 3, 4 and 5? Why do you say I "already have them?"

def lookup( query )
  regex=$"${person.lastname},${person.firstname}: .*${query}=(\w+)"
  ....

lookup( "phone" )
lookup( "fax" )

Sure, I could set up a tuple or a dict but you pointed out yesterday
that that is inconvenient. If it's too inconvenient for people who are
printing things then I think it's too inconvenient for everyone.

(yes, I'm confident that there is a bug in my regexp logic -- you get
the picture!)
-- 
 Paul Prescod - Not encumbered by corporate consensus
New from Computer Associates: "Software that can 'think', sold by 
marketers who choose not to."