Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-13 Thread Andrew Durdin
On 9/6/05, Guido van Rossum [EMAIL PROTECTED] wrote: My hypothesis is that there are actually only two use cases that matter enough to be supported directly: (a) quickly print a bunch of items with spaces in between them and a trailing newline (b) print one or more items with precise

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-13 Thread Calvin Spealman
On 9/9/05, Guido van Rossum [EMAIL PROTECTED] wrote: While I laugh at the naive view of people who write things like Interface equality and neutrality would be a good thing in the language and seriously (? I didn't see a smiley) use this argument to plead for not making print() a built-in, I

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-11 Thread skip
(Maybe someone else has already raised this point. I'm a bit behind.) Martin Here goes something: for applications targeted to the web, where Martin newlines don't matter, the line breaks in _()'ed strings are Martin superfluous. How will you know you're generating output that

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-11 Thread Greg Ewing
Nick Coghlan wrote: Not to mention the annoyingly large number of fonts that make '`' and ''' look virtually identical :( Well, you need to be careful about choice of font for programming anyway, for 0/O, 1/l, etc. -- Greg Ewing, Computer Science Dept,

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-09 Thread Stephen J. Turnbull
Greg == Greg Ewing [EMAIL PROTECTED] writes: Greg Stephen J. Turnbull wrote: IMO strings that are being printf'd can probably be assumed to be human readable, and therefore candidates for translation. This Greg That's a dangerous assumption to make, I think. Could be.

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-09 Thread Fredrik Lundh
Greg Ewing wrote: Maybe backquotes could be repurposed in Py3k for interpolated string literals? backquotes are a PITA to type on many non-US keyboards. /F ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-09 Thread Thomas Heller
Fredrik Lundh [EMAIL PROTECTED] writes: Greg Ewing wrote: Maybe backquotes could be repurposed in Py3k for interpolated string literals? backquotes are a PITA to type on many non-US keyboards. Even more since they are especially broken in Windows XEmacs. Thomas

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-09 Thread Guido van Rossum
On 9/8/05, Stephen J. Turnbull [EMAIL PROTECTED] wrote: Could be. For me, the name print is associated with a long history of magical behavior that only a human could possibly feel comfortable with. One of the great sins of Pascal was tarring the name write with the same brush! Well, apart

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-09 Thread skip
Fredrik backquotes are a PITA to type on many non-US keyboards. Interesting. On US keyboards they are often easier to type than parens... Skip ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-09 Thread Martin Blais
On 9/8/05, Antoine Pitrou [EMAIL PROTECTED] wrote: Hi, Le jeudi 08 septembre 2005 à 19:12 +0900, Stephen J. Turnbull a écrit : It would be nice to be able to lose the _() calls to gettext(). The function would look to see if a message catalog was available for the current output

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-08 Thread Stephen J. Turnbull
Guido == Guido van Rossum [EMAIL PROTECTED] writes: Guido I certainly didn't mean to rule that out. Speaking for myself, that's all I really wanted to hear at this time. As Bob Ippolito said, currently it's straightforward to internationalize an application, and well worth the minimal

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-08 Thread Antoine Pitrou
Hi, Le jeudi 08 septembre 2005 à 19:12 +0900, Stephen J. Turnbull a écrit : It would be nice to be able to lose the _() calls to gettext(). The function would look to see if a message catalog was available for the current output stream, and if not, do no translation. That doesn't sound

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-08 Thread Michael Chermside
Guido writes: Is it worth doing this and completely dropping the %-based formats in Py3k? (Just asking -- it might be if we can get people to get over the shock of $ becoming first class ;-). In my opinion, YES -- it's worth seriously considering it. A single, well-designed solution for string

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-08 Thread Barry Warsaw
On Wed, 2005-09-07 at 08:55, Nick Coghlan wrote: The leading 'p' (for 'positional') is necessary to get around the fact that $1 is currently an illegal identifier in a Template That should be fixable. Ideally, $1 is better than $p1. -Barry signature.asc Description: This is a digitally

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-08 Thread Barry Warsaw
On Wed, 2005-09-07 at 15:07, Bob Ippolito wrote: I was also able to easily automate the process of extracting strings to create that spreadsheet. I wrote a simple script that parsed the Python modules and looked for function calls of _ whose only argument was a constant string. Worked

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-08 Thread Barry Warsaw
On Thu, 2005-09-08 at 07:48, Antoine Pitrou wrote: As I said Python needs an operator or function that does string formatting using a simple template, *without* doing output at the same time. The current syntax is the '%' operator, it could change, but it shouldn't be removed in favor of an

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-08 Thread Nick Coghlan
Barry Warsaw wrote: On Wed, 2005-09-07 at 08:55, Nick Coghlan wrote: The leading 'p' (for 'positional') is necessary to get around the fact that $1 is currently an illegal identifier in a Template That should be fixable. Ideally, $1 is better than $p1. I also looked into the idea of

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-08 Thread Calvin Spealman
On 9/6/05, Guido van Rossum [EMAIL PROTECTED] wrote: On 9/5/05, Calvin Spealman [EMAIL PROTECTED] wrote: There is a lot of debate over this issue, obviously. Now, I think getting rid of the print statement can lead to ugly code, because a write function would be called as an expression, so

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-08 Thread Tommy Burnette
Michael Chermside writes: | Guido writes: | Is it worth doing this and completely dropping the %-based formats in | Py3k? (Just asking -- it might be if we can get people to get over the | shock of $ becoming first class ;-). | | In my opinion, YES -- it's worth seriously considering it. A

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-08 Thread Bob Ippolito
On Sep 8, 2005, at 5:42 AM, Barry Warsaw wrote: On Wed, 2005-09-07 at 15:07, Bob Ippolito wrote: I was also able to easily automate the process of extracting strings to create that spreadsheet. I wrote a simple script that parsed the Python modules and looked for function calls of _ whose

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-08 Thread Greg Ewing
Stephen J. Turnbull wrote: IMO strings that are being printf'd can probably be assumed to be human readable, and therefore candidates for translation. This That's a dangerous assumption to make, I think. I'd be uncomfortable with having some strings in my program translated automatically

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-07 Thread Stephen J. Turnbull
Guido == Guido van Rossum [EMAIL PROTECTED] writes: Guido Sure, we must provide good i18n support. But the burden on Guido users who don't need i18n should be negligeable; they Guido shouldn't have to type or know extra stuff that only exists Guido for the needs of i18n. Agreed.

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-07 Thread Barry Warsaw
On Wed, 2005-09-07 at 05:23, Stephen J. Turnbull wrote: But print-ng looks like becoming the OOWTDI for a lot of applications. IMO it's just too early to give up on print-ng becoming the one obvious way to do it for a lot of i18n apps, too. +1. I have a gut feeling that we can make it easy

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-07 Thread Nick Coghlan
Barry Warsaw wrote: On Wed, 2005-09-07 at 05:23, Stephen J. Turnbull wrote: But print-ng looks like becoming the OOWTDI for a lot of applications. IMO it's just too early to give up on print-ng becoming the one obvious way to do it for a lot of i18n apps, too. +1. I have a gut feeling

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-07 Thread Nick Coghlan
Nick Coghlan wrote: I found the following to be an interesting experiment: - from string import Template def format(*args, **kwds): fmt = args[0] kwds.update((p%s % idx, arg) for idx, arg in enumerate(args)) return Template(fmt).substitute(**kwds) I

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-07 Thread Guido van Rossum
On 9/7/05, Barry Warsaw [EMAIL PROTECTED] wrote: On Wed, 2005-09-07 at 05:23, Stephen J. Turnbull wrote: But print-ng looks like becoming the OOWTDI for a lot of applications. IMO it's just too early to give up on print-ng becoming the one obvious way to do it for a lot of i18n apps,

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-07 Thread Bob Ippolito
On Sep 7, 2005, at 7:11 AM, Guido van Rossum wrote: On 9/7/05, Barry Warsaw [EMAIL PROTECTED] wrote: On Wed, 2005-09-07 at 05:23, Stephen J. Turnbull wrote: But print-ng looks like becoming the OOWTDI for a lot of applications. IMO it's just too early to give up on print-ng becoming

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-07 Thread Chris Smith
Guido == Guido van Rossum [EMAIL PROTECTED] writes: Guido intermezzo Guido In a different thread I mentioned a design principle for Guido which I have no catchy name, but which has often helped me Guido design better APIs. One way to state it is to say that Guido instead of

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread [EMAIL PROTECTED]
Guido van Rossum [EMAIL PROTECTED] wrote: What do you think of the trick (that I wasn't aware of before) used in Java and .net of putting an optional position specifier in the format, and using positional arguments? It would be a little less verbose and with sensible defaults wouldn't quite

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Nick Coghlan
Guido van Rossum wrote: If there are other use cases they can obviously be coded by using (b) and a modest amount of custom code. (I know there's the use case of printing sequences; I'll try to give an analysis of this use case in another post if one of its proponents doesn't do so soon.)

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Barry Warsaw
On Tue, 2005-09-06 at 00:56, Guido van Rossum wrote: On 9/5/05, Barry Warsaw [EMAIL PROTECTED] wrote: Eliminating the newline argument from print() would reduce the number of reserved keyword arguments in my strawman by half. Maybe we could even rename 'to' to '__to__' (!) to eliminate the

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Greg Ewing
Guido van Rossum wrote: So let's call it the Swiss Army Knife (...Not) API design pattern. Aha! Maybe this is the long-lost 20th principle from the Zen of Python? Greg ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Nick Coghlan
Greg Ewing wrote: Guido van Rossum wrote: So let's call it the Swiss Army Knife (...Not) API design pattern. Aha! Maybe this is the long-lost 20th principle from the Zen of Python? It also sounds like one of the reasons why the ultimates in programming swiss army knives (that is, Lisp

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Guido van Rossum
On 9/5/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Positional arguments remove too much meaning from the template. Compare: '$user forgot to frobnicate the $file!\n' with '$1 forgot to frobnicate the $2!\n' Whenever the template definition and its use are not directly

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Guido van Rossum
On 9/6/05, Nick Coghlan [EMAIL PROTECTED] wrote: I did a fair bit of tinkering with that on the weekend. Printing a sequence of strings is fine - it's the call to map(str, seq) that makes printing a sequence of non-strings uglier than it should be. Doing it that way also breaks the Python

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Guido van Rossum
On 9/6/05, Barry Warsaw [EMAIL PROTECTED] wrote: printf('$1 forgot to frobnicate the $2!\n', username, file.name, to=sys.stderr) While that's a little less self-descriptive for a translator to deal with (who would only see the string, not the call site), it certainly looks nicer for

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread [EMAIL PROTECTED]
Guido van Rossum [EMAIL PROTECTED] wrote : On 9/5/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Whenever the template definition and its use are not directly adjacent, the template is that much harder to understand (i.e., This `i.e.` should have read `e.g.` :-( in the context of

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Antoine Pitrou
(just my 2 cents) Le mardi 06 septembre 2005 à 07:23 -0700, Guido van Rossum a écrit : On 9/6/05, Barry Warsaw [EMAIL PROTECTED] wrote: printf('$1 forgot to frobnicate the $2!\n', username, file.name, to=sys.stderr) Is it worth doing this and completely dropping the %-based formats

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread rzed
Guido van Rossum [EMAIL PROTECTED] wrote: [...] OK, still with me? This, together with the observation that the only use cases for the delimiter are space and no space, suggests that we should have separate printing APIs for each of the use cases (a), (b) and (c) above, rather than

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Michael Hudson
Guido van Rossum [EMAIL PROTECTED] writes: On 9/3/05, Bill Janssen [EMAIL PROTECTED] wrote: So here's the summary of the arguments against: two style points (trailing comma and stream) (from the man who approved the current decorator syntax!), and it's hard to extend. (By the way, I agree

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Guido van Rossum
On 9/6/05, Michael Hudson [EMAIL PROTECTED] wrote: Gnyagh, couldn't you have *started* the thread with that post? :) I hadn't anticipated so many great minds rusted shut. :-) -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Gareth McCaughan
On 9/6/05, Barry Warsaw [EMAIL PROTECTED] wrote: printf('$1 forgot to frobnicate the $2!\n', username, file.name, to=sys.stderr) ... For me, the problem with that proposal is not the precise format syntax, but the fact that formatting is tied to a specific function which _also_

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Paul Moore
On 9/6/05, Gareth McCaughan [EMAIL PROTECTED] wrote: So borrow a trick from Common Lisp and use a destination of None to mean return the formatted text as a string. [...] Or is that too cryptic? Yes. To my mind, formatting (returning a string) and output are separate operations. A write

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Kay Schluehr
Nick Coghlan wrote: Greg Ewing wrote: Guido van Rossum wrote: So let's call it the Swiss Army Knife (...Not) API design pattern. Aha! Maybe this is the long-lost 20th principle from the Zen of Python? It also sounds like one of the reasons why the ultimates in programming swiss army

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Trent Mick
[Barry Warsaw wrote] Also, we already have precedence in format+print in the logging package. I actually think the logging provides a nice, fairly to use interface that print-ng can be modeled on. The main reason for doing that in the logging package is for performance: processing the args

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Delaney, Timothy (Tim)
Michael Chermside wrote: We could satisfy both people if in Python 2.x we introduced a built-in function named print30 (for Python 3.0) with the intended new behavior. People could start coding now using the print30 builtin. When Python 3.0 was released, 'print' would no longer be a keyword,

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Bill Janssen
LOL! That's a great solution for the 5 of us dinosaurs still using the One True Editor. :) And who also still program in C now and then :-). I think there are more than 5 of us, though. Bill ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Bill Janssen
Guido van Rossum wrote: So let's call it the Swiss Army Knife (...Not) API design pattern. IIRC, this is one of the design principles which inspired Lisp mixins. The idea was that different interfaces should be separated into different classes. If you needed a class which combined them, you'd

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Meyer, Tony
In the end the process is not democratic. Which may make it easier: rather than having to convince 50%+ of the people, one only has to convince a single person... I don't think there's anything that can change my mind about dropping the statement. As long as I don't think there's anything

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Stephen J. Turnbull
Guido == Guido van Rossum [EMAIL PROTECTED] writes: Guido I'm not at all convinced that we should attempt to find a Guido solution that handles both use cases [print replacement Guido and i18n]; most Python code never needs i18n. It's true that the majority of Python applications

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-06 Thread Guido van Rossum
On 9/6/05, Stephen J. Turnbull [EMAIL PROTECTED] wrote: It's true that the majority of Python applications never need i18n, because they're only used in one language. But Python applications are mostly assembled from a large and growing set of Python-standard and other well-known libraries.

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-05 Thread Fredrik Lundh
Steven Bethard wrote: Use the print() method of sys.stderr: sys.stderr.print('error or help message') so who's going to add print methods to all file-like objects? The same people that added __iter__(), next(), readline(), readlines() and writelines() to their file-like objects who

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-05 Thread Stephan Deibel
On Mon, 5 Sep 2005, Martin Blais wrote: However, there is an easy way out: hijack sys.stdout to forward to your logger system. I've got a web application framework that's setup like that right now, it works great (if you will not need the original print-to-stdout anymore in your program, that

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-05 Thread Simon Percivall
On 5 sep 2005, at 18.56, Stephan Deibel wrote: On Mon, 5 Sep 2005, Martin Blais wrote: However, there is an easy way out: hijack sys.stdout to forward to your logger system. I've got a web application framework that's setup like that right now, it works great (if you will not need the

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-05 Thread Kay Schluehr
Guido van Rossum wrote: I see two different ways to support the two most-called-for additional requirements: (a) an option to avoid the trailing newline, (b) an option to avoid the space between items. One way would be to give the print() call additional keyword arguments. For example,

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-05 Thread Guido van Rossum
On 9/5/05, Kay Schluehr [EMAIL PROTECTED] wrote: [...] is the most heavyweight solution, but can encapsulate options and is reusable: Writer(sep=//).print(some,text) some//text or writer = Writer(sep=//, file=sys.stderr) writer.print(some,error-text) writer.print(another,error

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-05 Thread Barry Warsaw
On Mon, 2005-09-05 at 20:52, Guido van Rossum wrote: We could decide not to provide (b) directly, since it is easily reduced to (c) using an appropriate format string (%s times the number of arguments). But I expect that use case (b) is pretty important, and not everyone likes having to use

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-05 Thread skip
Neil In interactive mode, you are normally interested in the values of Neil things, not their formatting so it does the right thing. class Dumb: ... def __init__(self, val): ... self.val = val ... def __str__(self): ... return Dumb val=%s % self.val

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-05 Thread Brett Cannon
On 9/5/05, Barry Warsaw [EMAIL PROTECTED] wrote: On Mon, 2005-09-05 at 20:52, Guido van Rossum wrote: We could decide not to provide (b) directly, since it is easily reduced to (c) using an appropriate format string (%s times the number of arguments). But I expect that use case (b) is

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-05 Thread Calvin Spealman
On 9/1/05, Guido van Rossum [EMAIL PROTECTED] wrote: [Charles Cazabon] Perhaps py3k could have a py2compat module. Importing it could have the effect of (for instance) putting compile, id, and intern into the global namespace, making print an alias for writeln, [Greg Ewing]

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-05 Thread Guido van Rossum
On 9/5/05, Barry Warsaw [EMAIL PROTECTED] wrote: Eliminating the newline argument from print() would reduce the number of reserved keyword arguments in my strawman by half. Maybe we could even rename 'to' to '__to__' (!) to eliminate the other namespace wart. Is this really too horrible:

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Tony Meyer
[Nick Coghlan] Print as statement = printing sequences nicely is a pain What's wrong with this? print range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] print tuple(string) ('s', 't', 'r', 'i', 'n', 'g') This is a serious question - that's how I would expect a print function to work anyway. Print as

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Tony Meyer
[...] maybe a few folks can go off and write up a PEP for a print-replacement. [...] I'm pulling out of the discussion until I see a draft PEP. If there are two competing proposals, then the two groups write a PEP and counter-PEP and the PEPs duke it out. Is this still the case if

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Nick Coghlan
Tony Meyer wrote: [...] maybe a few folks can go off and write up a PEP for a print-replacement. [...] I'm pulling out of the discussion until I see a draft PEP. If there are two competing proposals, then the two groups write a PEP and counter-PEP and the PEPs duke it out. Is

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Nick Coghlan
Tony Meyer wrote: [Nick Coghlan] Print as statement = printing sequences nicely is a pain What's wrong with this? print range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] print tuple(string) ('s', 't', 'r', 'i', 'n', 'g') This is a serious question - that's how I would expect a print

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Neil Hodgson
Gareth McCaughan: Interactive use is its own mode and works differently to the base language. To print the value of something, just type an expression. Doesn't do the same thing. In interactive mode, you are normally interested in the values of things, not their formatting so it

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Guido van Rossum
On 9/3/05, Tony Meyer [EMAIL PROTECTED] wrote: If there are two competing proposals, then the two groups write a PEP and counter-PEP and the PEPs duke it out. Is this still the case if proposal B is very nearly the status quo? No. The primary argument is between keeping the print statement

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Guido van Rossum
On 9/4/05, Nick Coghlan [EMAIL PROTECTED] wrote: Keeping print as a statement is certainly one of the options I'm considering, so I don't think a counter-PEP is warranted just yet. There isn't even a PEP to be a counter to - it's all still on the Wiki at the moment. I am so far a bit

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Guido van Rossum
On 9/3/05, Bill Janssen [EMAIL PROTECTED] wrote: So here's the summary of the arguments against: two style points (trailing comma and stream) (from the man who approved the current decorator syntax!), and it's hard to extend. (By the way, I agree that the syntax is ugly, and IMO a bad idea

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Barry Warsaw
On Sat, 2005-09-03 at 12:51, James Y Knight wrote: On Sep 3, 2005, at 11:32 AM, Barry Warsaw wrote: So I think it's best to have two builtins: print(*args, **kws) printf(fmt, *args, **kws) It seems pretty bogus to me to add a second builtin just to apply the % operator for you.

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Barry Warsaw
On Sat, 2005-09-03 at 14:42, Paul Moore wrote: I have to agree. While I accept that Barry has genuine use cases for the printf form, I don't quite see why %-formatting isn't enough. Is the print-plus-% form so much less readable and/or maintainable? IMO, yes. I can't tell you how many times

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Barry Warsaw
On Sat, 2005-09-03 at 13:12, Martin Blais wrote: (defun python-abbrev-print () Help me change old habits. (insert print()) (backward-char 1) t) (put 'python-abbrev-print 'no-self-insert t) (define-abbrev python-mode-abbrev-table print 'python-abbrev-print) LOL! That's a great solution

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Raymond Hettinger
[Barry] Actually, we probably only /need/ printf(), and certainly for C programmers (are there any of us left? ;), I think that would be a small conceptual leap. The motivation for keeping a non-formatting version is for simple cases, and beginners -- both of which use cases should not be

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Martin Blais
On 9/4/05, Tony Meyer [EMAIL PROTECTED] wrote: Yes. If it didn't have the redirect stuff; I would like it more if it also didn't have the trailing comma magic. print is a fundamental; it deserves to be a statement :) I don't know exactly what you mean by fundamental, in opposition to your

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread François Pinard
[Guido van Rossum] [...] print is the only application-level functionality that has a statement dedicated to it. Within Python's world, syntax is generally used as a last resort, when something *can't* be done without help from the compiler. Print doesn't qualify for such an exception

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Stephan Deibel
On Sun, 4 Sep 2005, Guido van Rossum wrote: But more important to me are my own experiences exploring the boundaries of print. - I quite often come to a point in the evolution of a program where I need to change all print statements into logging calls, or calls into some other I/O or UI

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Terry Reedy
Guido van Rossum [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Summarizing, my main problems with print as a statement are the transformations -- when print doesn't cut it, you have to switch to something entirely different. If it were a function the switch would feel much

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Greg Ewing
Meyer, Tony wrote: print is the best example I can think of for practicality beats purity. Writing to stdout is as common in the code I write as loops - it's worth keeping such basic functionality as elegant, simple, easy to understand, and easy to use as possible. If writing to stdout

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread James Y Knight
On Sep 4, 2005, at 12:51 PM, Barry Warsaw wrote: On Sat, 2005-09-03 at 12:51, James Y Knight wrote: On Sep 3, 2005, at 11:32 AM, Barry Warsaw wrote: So I think it's best to have two builtins: print(*args, **kws) printf(fmt, *args, **kws) It seems pretty bogus to me to add a second

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Barry Warsaw
On Sat, 2005-09-03 at 22:08, Nick Coghlan wrote: See a (very quick and very dirty ;) strawman that I just posted to the wiki. I think this has some interesting semantics, including the ability to control the separator inline in a C++-like fashion. The writef() version also accepts

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Barry Warsaw
On Sun, 2005-09-04 at 11:59, Guido van Rossum wrote: I agree that those are strong arguments, so please hear me out. Thanks Guido, I think your arguments are powerful too. -Barry signature.asc Description: This is a digitally signed message part

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Barry Warsaw
On Sun, 2005-09-04 at 22:06, James Y Knight wrote: No, we certainly don't /need/ printf(), as is well proven by its current absence. Having the operation of printing and the operation of string formatting be separated is good, because it means you can easily do either one without the

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-04 Thread Barry Warsaw
On Sun, 2005-09-04 at 22:32, Guido van Rossum wrote: Right. I just have one additional suggestion for the logging package (not sure if it should apply to printf as well): if there's a problem with the format operator, fall back to printing the format string followed by the argument values (if

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Fredrik Lundh
Steven Bethard wrote: - Error and help messages, often with print sys.stderr Use the print() method of sys.stderr: sys.stderr.print('error or help message') so who's going to add print methods to all file-like objects? /F ___ Python-Dev

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Paolino
Martin Blais wrote: On 9/2/05, Phillip J. Eby [EMAIL PROTECTED] wrote: At 11:02 AM 9/3/2005 +1000, Nick Coghlan wrote: Printing the items in a sequence also becomes straightforward: print .join(map(str, range(10))) = output(*range(10)) Playing well with generator expressions comes for free,

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Paul Moore
On 9/3/05, Guido van Rossum [EMAIL PROTECTED] wrote: Wow. With so many people expressing a gut response and not saying what in the proposal they don't like, it's hard to even start a response. Fair point. Is it... - Going from statement to function? I thought this was a major issue,

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Paul Moore
On 9/3/05, Nick Coghlan [EMAIL PROTECTED] wrote: [...] Playing well with generator expressions comes for free, too: print .join(str(x*x) for x in range(10)) = output(*(x*x for x in range(10))) Hmm... This prompts a coding question - is it possible to recognise which arguments to a

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Martin Blais
On 9/3/05, Paolino [EMAIL PROTECTED] wrote: Martin Blais wrote: Then how about:: output(*(x*x for x in range(10)), iter=1) Illegal in python2.4.(Wrongly ?) And makes the star solution half unuseful. def f(*args,**kwargs): ... pass ... f(*(1,2,3),iter=True) File stdin,

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Nick Coghlan
Paul Moore wrote: Hmm... This prompts a coding question - is it possible to recognise which arguments to a function are generators, so that you could write output(1, 2, [3,4], (c for c in 'abc'), 'def', (5, 6)) and get 1 2 [3, 4] a b c def (5, 6) ? At the simplest level,

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Paolino
Nick Coghlan wrote: If an iterator wants to behave like that, the iterator should define the appropriate __str__ method. Otherwise, just break it up into multiple lines: write(1, 2, [3,4]) write(*(c for c in 'abc')) This cannot accept keyword args(I wonder if this is a bug), which

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Nick Coghlan
Paolino wrote: Nick Coghlan wrote: If an iterator wants to behave like that, the iterator should define the appropriate __str__ method. Otherwise, just break it up into multiple lines: write(1, 2, [3,4]) write(*(c for c in 'abc')) This cannot accept keyword args(I wonder if

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Barry Warsaw
On Fri, 2005-09-02 at 21:42, Guido van Rossum wrote: With so many people expressing a gut response and not saying what in the proposal they don't like, it's hard to even start a response. Is it... - Going from statement to function? So I ignored my visceral reaction against the proposal and

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Guido van Rossum
So, another round. * Gratuitous breakage: IMO it's not gratuitous. The *extensions* to the print statement (trailing comma, stream) are ugly, and because it's all syntax, other extensions are hard to make. Had it been a function from the start it would have been much easier to add keyword args,

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Raymond Hettinger
[Barry Warsaw] I think it's best to have two builtins: print(*args, **kws) printf(fmt, *args, **kws) I would also /require/ that any behavior changing keyword arguments /not/ be magically inferred from the positional arguments. So you'd have to explicitly spell 'nl=False' or stream=fp

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Barry Warsaw
On Sat, 2005-09-03 at 11:17, Guido van Rossum wrote: I see two different ways to support the two most-called-for additional requirements: (a) an option to avoid the trailing newline, (b) an option to avoid the space between items. See a (very quick and very dirty ;) strawman that I just

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread James Y Knight
On Sep 3, 2005, at 11:32 AM, Barry Warsaw wrote: So I think it's best to have two builtins: print(*args, **kws) printf(fmt, *args, **kws) It seems pretty bogus to me to add a second builtin just to apply the % operator for you. I've always really liked that Python doesn't have separate

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Martin Blais
On 9/3/05, Barry Warsaw [EMAIL PROTECTED] wrote: On Fri, 2005-09-02 at 21:42, Guido van Rossum wrote: I do hate having to write two parentheses -- it's more than the extra keystrokes. It's that I have to use two shifted characters and I have to be sure to close the construct, which can be a

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Steven Bethard
Fredrik Lundh wrote: Steven Bethard wrote: - Error and help messages, often with print sys.stderr Use the print() method of sys.stderr: sys.stderr.print('error or help message') so who's going to add print methods to all file-like objects? The same people that added __iter__(),

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Steven Bethard
Guido van Rossum wrote: If there's demand, we could also introduce printf(), which would work just like C's printf() except it takes a keyword argument to redirect the output. I think this is probably unnecessary if string formatting becomes a function instead of the % operator (as has been

Re: [Python-Dev] Replacement for print in Python 3.0

2005-09-03 Thread Guido van Rossum
On 9/3/05, Nick Coghlan [EMAIL PROTECTED] wrote: Actually, it's an ordering quirk in the parser - the extended call syntax stuff has to come last in the function call, which means we need to put the keyword arguments at the front: Py writeln(sep=', ', *(x*x for x in range(10))) 0, 1, 4, 9,

  1   2   >