Re: [Python-Dev] String views (was: Re: Proof of the pudding:str.partition())

2005-09-01 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: >Fredrik> Python strings are character buffers with a known length, not >Fredrik> null-terminated C strings. the CPython implementation >Fredrik> guarantees that the character buffer has a trailing NULL >Fredrik> character, but that's mostly to make it eas

Re: [Python-Dev] String views

2005-09-01 Thread Stephen J. Turnbull
> "Steve" == Steve Holden <[EMAIL PROTECTED]> writes: Steve> Since Python strings *can* contain embedded NULs, doesn't Steve> that rather poo on the idea of passing pointers to their Steve> data to C functions as things stand? I think it's a "consenting adults" issue. Ie, C progr

Re: [Python-Dev] String views

2005-09-01 Thread Steve Holden
Greg Ewing wrote: > [EMAIL PROTECTED] wrote: > >>If I then wanted to see what scheme's value >>compared to, the string's comparison method would have to recognize that it >>wasn't truly NUL-terminated, copy it, call strncmp() or whatever underlying >>routine is used for string comparisons. > > >

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

2005-09-01 Thread Martin Blais
On 9/1/05, Bill Janssen <[EMAIL PROTECTED]> wrote: > > Providing you can live with adding a pair of parentheses to that, you can > > have: > > > >def print(*args): > > sys.stdout.write(' '.join(args) + '\n') > > > > I think the language would be cleaner if it lacked this weird exception f

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

2005-09-01 Thread Steve Holden
Steven Bethard wrote: > [Guido van Rossum] > >>And good riddance! The print statement harks back to ABC and even >>(unvisual) Basic. Out with it! > > > [Barry Warsaw] > >>I have to strongly disagree. The print statement is simple, easy to >>understand, and easy to use. > > > [Paul Moore] >

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

2005-09-01 Thread Greg Ewing
Steven Bethard wrote: > I think we *do* > need a statement or function of some sort that does the most basic > task: writing a line to sys.stdout that calls str() on each of the > elements and joins them with spaces. Hypertalk (the programming language of Apple's Hypercard) had an interesting way

Re: [Python-Dev] String views

2005-09-01 Thread Josiah Carlson
[EMAIL PROTECTED] wrote: > >> I'm skeptical about performance as well, but not for that reason. A > >> string object can have a referent field. If not NULL, it refers to > >> another string object which is INCREFed in the usual way. At string > >> deallocation, if the referent i

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

2005-09-01 Thread Greg Ewing
Shane Hathaway wrote: > May I also suggest the following shortcut for creating and evaluating a > string template. (Ever since I thought of this, I've actually used this > in code without thinking... it's just too natural): > >message = $"Hello, $name!" As I recall, this has been consider

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

2005-09-01 Thread skip
>> And good riddance! The print statement harks back to ABC and even >> (unvisual) Basic. Out with it! Barry> I have to strongly disagree. The print statement is simple, easy Barry> to understand, and easy to use. I'm with Barry. Even for non-debug use the print statement is su

Re: [Python-Dev] String views

2005-09-01 Thread skip
>> I'm skeptical about performance as well, but not for that reason. A >> string object can have a referent field. If not NULL, it refers to >> another string object which is INCREFed in the usual way. At string >> deallocation, if the referent is not NULL, the referent is DECRE

Re: [Python-Dev] Python 3 design principles

2005-09-01 Thread Fred L. Drake, Jr.
On Thursday 01 September 2005 23:00, [EMAIL PROTECTED] wrote: > Then why remove it at all? Bingo. I don't see any need to remove it. I could live with removing the trailing-comma semi-wart, but there just isn't any need to remove it. -Fred -- Fred L. Drake, Jr. ___

Re: [Python-Dev] Python 3 design principles

2005-09-01 Thread skip
>> I still hope to see this change to "make print a builtin instead of a >> statement". I'd hate to lose the one-line hello world example due to >> cruft like "from sys import stdout". Barry> I agree. You can't get much simpler to explain or use than the Barry> current print

Re: [Python-Dev] Python 3 design principles

2005-09-01 Thread Greg Ewing
Reinhold Birkenfeld wrote: > Greg Ewing wrote: > >>There's no way importing a module could add something that >>works like the old print statement, unless some serious >>magic is going on... > > You'd have to enclose print arguments in parentheses. Of course, the "trailing > comma" form would be

Re: [Python-Dev] String views (was: Re: Proof of the pudding:str.partition())

2005-09-01 Thread skip
Fredrik> Python strings are character buffers with a known length, not Fredrik> null-terminated C strings. the CPython implementation Fredrik> guarantees that the character buffer has a trailing NULL Fredrik> character, but that's mostly to make it easy to pass Python Fredrik>

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

2005-09-01 Thread Ron Adam
Jim Jewett wrote: > >>Another real problem with print is that, while the >>automatic insertion of spaces is nice for beginners, >>it often gets in the way, and what you have to do to >>avoid this is pretty nasty: either drop print altogether >>in favor of sys.stdout.write(), or use string concate

[Python-Dev] Replacement for print in Python 3.0

2005-09-01 Thread Jim Jewett
Guido van Rossum suggested: >stream.write(a1, a2, ...) >stream.writeln(a1, a2, ...) >stream.writef(fmt, a1, a2, ...) > builtin functions write(), writeln(), writef() that call the > corresponding method on sys.stdout. These seem good, except that write typically matches read, and I

[Python-Dev] Python 3 design principles

2005-09-01 Thread Jim Jewett
Nick Craig-Wood wrote: > If come python 3, there is a 99% accurate program which can turn your > python 2.x into python 3 code, then that would ease the transition > greatly. Guido wrote: > That might not be so easy given the desire to change most > list-returning functions and methods into iter

[Python-Dev] String views

2005-09-01 Thread Jim Jewett
Tim Delaney writes: > One of the big disadvantages of string views is that they need to keep > the original object around, no matter how big it is. But in the case of > partition, much of the time the original string survives for at least a > similar period to the partitions. Michael Chermside wri

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

2005-09-01 Thread Eli Stevens (WG.c)
Guido van Rossum wrote: > It seems to me that, as long as write() and writeln() were built-ins > taking multiple args, teaching a beginner to use > > writeln("The answer is: ", 4+4) > > > is perfectly clear (and might be a gentle introduction to function > calls as well). Hello, I'm Eli

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

2005-09-01 Thread Bob Ippolito
On Sep 1, 2005, at 2:27 PM, Jack Diederich wrote: > On Thu, Sep 01, 2005 at 11:12:57PM +0200, Fredrik Lundh wrote: > >> Charles Cazabon wrote: >> >> >>> in fact, it does nothing for the program but merely has the >>> interesting >>> side-effect of writing to stdout. >>> >> >> yeah, real program

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

2005-09-01 Thread Charles Cazabon
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Charles Cazabon wrote: > > > in fact, it does nothing for the program but merely has the interesting > > side-effect of writing to stdout. > > yeah, real programmers don't generate output. That wasn't quite my point - I meant that the rest of Python's s

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

2005-09-01 Thread Steven Bethard
Reinhold Birkenfeld wrote: > Raymond Hettinger wrote: > > Actually, formatting needs to become a function. The overloading of the > > arithmetic mod operator has proven to be unfortunate (if only because of > > precedence issues). > > But then, a format() function would be necessary (equivalent t

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

2005-09-01 Thread Jack Diederich
On Thu, Sep 01, 2005 at 11:12:57PM +0200, Fredrik Lundh wrote: > Charles Cazabon wrote: > > > in fact, it does nothing for the program but merely has the interesting > > side-effect of writing to stdout. > > yeah, real programmers don't generate output. > I'd say: yeah, real programmers don't

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

2005-09-01 Thread Reinhold Birkenfeld
Raymond Hettinger wrote: >> Do we really need writef()? It seems to be not much better than its %- >> formatting >> equivalent. > > Actually, formatting needs to become a function. The overloading of the > arithmetic mod operator has proven to be unfortunate (if only because of > precedence issue

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

2005-09-01 Thread Fredrik Lundh
Charles Cazabon wrote: > in fact, it does nothing for the program but merely has the interesting > side-effect of writing to stdout. yeah, real programmers don't generate output. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python

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

2005-09-01 Thread Bill Janssen
> Providing you can live with adding a pair of parentheses to that, you can > have: > >def print(*args): > sys.stdout.write(' '.join(args) + '\n') > > I think the language would be cleaner if it lacked this weird exception for > `print`. Charles, I agree that it would be cleaner. I j

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

2005-09-01 Thread Jack Diederich
On Thu, Sep 01, 2005 at 02:46:13PM -0600, Charles Cazabon wrote: > Bill Janssen <[EMAIL PROTECTED]> wrote: > > I don't use "print" myself much, but for the occasional 3-line script. > > But I think the user-friendliness of it is a good point, and makes up > > for the weirdness of it all. There's s

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

2005-09-01 Thread BJörn Lindqvist
Something I've noticed from teaching C++ to newbies, is that you should NOT (never ever) start with "cout << "Hello, world!" << endl;". You should start with "printf("Hello, world\n");" The cout thingy is impossible to explain to a newbie because it uses much underlying "magic" and has a very diffe

Re: [Python-Dev] Python 3 design principles

2005-09-01 Thread Ron Adam
Reinhold Birkenfeld wrote: > Greg Ewing wrote: > >>Charles Cazabon wrote: >> >> >>>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, >> >>There's no w

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

2005-09-01 Thread Guido van Rossum
On 9/1/05, Fredrik Johansson <[EMAIL PROTECTED]> wrote: > Why not instead change the language so as to allow any function call > to be written without parentheses (when this is unambiguous)? This > could make Python more convenient for creating imperative-style DSLs > (though I'm not sure this is a

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

2005-09-01 Thread Charles Cazabon
Bill Janssen <[EMAIL PROTECTED]> wrote: > > And good riddance! The print statement harks back to ABC and even > > (unvisual) Basic. Out with it! I'm with Guido on this, BTW. > After reviewing the PEP 3000 notes, I can find no justification there > for removing "print" Well, how about the fact th

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

2005-09-01 Thread Bill Janssen
I don't use "print" myself much, but for the occasional 3-line script. But I think the user-friendliness of it is a good point, and makes up for the weirdness of it all. There's something nice about being able to write print "the answer is", 3*4+10 which is one of the reasons ABC and BASIC hav

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

2005-09-01 Thread Charles Cazabon
Bill Janssen <[EMAIL PROTECTED]> wrote: > I don't use "print" myself much, but for the occasional 3-line script. > But I think the user-friendliness of it is a good point, and makes up > for the weirdness of it all. There's something nice about being able > to write > > print "the answer is", 3

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

2005-09-01 Thread Bill Janssen
I see this is Fredrik's earlier suggestion. Bill I (reduntantly) wrote: > Is there a syntax trick here? Suppose start-of-the-line function > names not followed by an open-paren, but followed by comma-separated > lists of expressions, were treated as if the rest of the line were > arguments to a

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

2005-09-01 Thread Guido van Rossum
On 9/1/05, Bill Janssen <[EMAIL PROTECTED]> wrote: > After reviewing the PEP 3000 notes, I can find no justification there > for removing "print" other than your statement here -- that it has > served honorably and well in many programming languages for many > years, a curious reason for abandoning

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

2005-09-01 Thread Steven Bethard
[Guido van Rossum] > And good riddance! The print statement harks back to ABC and even > (unvisual) Basic. Out with it! [Barry Warsaw] > I have to strongly disagree. The print statement is simple, easy to > understand, and easy to use. [Paul Moore] > I agree with Barry. In particular, the behavi

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

2005-09-01 Thread Shane Hathaway
Guido van Rossum wrote: > On 9/1/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > >>string.Template is a bit too simplified. But perhaps it can be adapted. >>We still want some way to express %r, %6.2f, etc.Since string >>formatting has been around since Tim was in diapers, we should probab

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

2005-09-01 Thread Bill Janssen
I have to agree with Barry, Paul, Fredrik, Reinhold, etc. Removing the "print" statement would immediately break at a fundamental level 15 years of tutorials, books, and examples, many of which start with >>> print "Hello, World!" Of course, maybe that's the idea -- this is not your father's Pyt

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

2005-09-01 Thread Bill Janssen
> And good riddance! The print statement harks back to ABC and even > (unvisual) Basic. Out with it! Guido, After reviewing the PEP 3000 notes, I can find no justification there for removing "print" other than your statement here -- that it has served honorably and well in many programming langua

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

2005-09-01 Thread Guido van Rossum
(Please don't send private replies.) On 9/1/05, Eric Nieuwland <[EMAIL PROTECTED]> wrote: > I have a lot of code that uses read()/write() to for binary file access. > Will that break by this change? > If so, I'd like to propose writes() instead of write() as proposed. No, that's the beauty. (Assu

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

2005-09-01 Thread Guido van Rossum
On 9/1/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > string.Template is a bit too simplified. But perhaps it can be adapted. > We still want some way to express %r, %6.2f, etc.Since string > formatting has been around since Tim was in diapers, we should probably > start by looking at the

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

2005-09-01 Thread Raymond Hettinger
> > Actually, formatting needs to become a function. The overloading of the > > arithmetic mod operator has proven to be unfortunate (if only because of > > precedence issues). > > For me, it's not so much the precedence, but the fact that "%s" % x > doesn't work as expected if x is a tuple; you'

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

2005-09-01 Thread Guido van Rossum
On 9/1/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > Do we really need writef()? It seems to be not much better than its %- > > formatting > > equivalent. > > Actually, formatting needs to become a function. The overloading of the > arithmetic mod operator has proven to be unfortunate (if

Re: [Python-Dev] partition() (was: Remove str.find in 3.0?)

2005-09-01 Thread Eric Nieuwland
Raymond Hettinger wrote: >> I think it's convenient but also rather odd that split() with a static >> string argument was moved from module string to a method in class str, >> while split() with a regexp has remained in module re. > > I don't see what you find odd. With str and unicode objects bei

Re: [Python-Dev] itertools.chain should take an iterable ?

2005-09-01 Thread Jack Diederich
On Thu, Sep 01, 2005 at 07:58:40PM +0200, Paolino wrote: > Working on a tree library I've found myself writing > itertools.chain(*[child.method() for child in self]). > Well this happened after I tried instinctively > itertools.chain(child.method() for child in self). > > Is there a reason for t

[Python-Dev] itertools.chain should take an iterable ?

2005-09-01 Thread Paolino
Working on a tree library I've found myself writing itertools.chain(*[child.method() for child in self]). Well this happened after I tried instinctively itertools.chain(child.method() for child in self). Is there a reason for this signature ? Regards paolino

Re: [Python-Dev] Proof of the pudding: str.partition()

2005-09-01 Thread William Trenker
On 9/1/05, Greg Ewing <[EMAIL PROTECTED]> wrote: > LD "Gus" Landis wrote: > > .piece() can be both a verb and a noun > > Er, pardon? I don't think I've ever heard 'piece' used > as a verb in English. Can you supply an example sentence? > - assemble: make by putting pieces together; "She pieced a

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

2005-09-01 Thread Raymond Hettinger
> Do we really need writef()? It seems to be not much better than its %- > formatting > equivalent. Actually, formatting needs to become a function. The overloading of the arithmetic mod operator has proven to be unfortunate (if only because of precedence issues). Also, the format coding schem

[Python-Dev] Weekly Python Patch/Bug Summary

2005-09-01 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 903 open (+551) / 5222 closed (+2324) / 6125 total (+2875) Bugs: 903 open (-23) / 5222 closed (+45) / 6125 total (+22) RFE : 187 open ( -3) / 184 closed ( +5) / 371 total ( +2) New / Reopened Patches __ PEP

Re: [Python-Dev] Revising RE docs

2005-09-01 Thread Guido van Rossum
On 8/31/05, Stephen J. Turnbull <[EMAIL PROTECTED]> wrote: > > "Michael" == Michael Chermside <[EMAIL PROTECTED]> writes: > > Michael> (2) is what we have today, but I would prefer (1) to > Michael> gently encourage people to use the precompiled objects > Michael> (which are distin

Re: [Python-Dev] Proof of the pudding: str.partition()

2005-09-01 Thread Raymond Hettinger
[Steve Holden] > The collective brainpower that's been exercised on this one enhancement > already must be phenomenal, but the proposal still isn't perfect. Sure it is :-) It was never intended to replace all string parsing functions, existing or contemplated. We still have str.index() so peop

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

2005-09-01 Thread Reinhold Birkenfeld
Guido van Rossum 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] >> > There's no way importi

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

2005-09-01 Thread Fredrik Johansson
I like the present print statement because parentheses are inconvenient to type compared to lowercase letters, and it looks less cluttered without them. The parentheses in writeln("hello world") don't add any more meaning than a terminating semicolon would, so why are they necessary? Why not inste

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

2005-09-01 Thread Paul Moore
On 9/1/05, Barry Warsaw <[EMAIL PROTECTED]> wrote: > On Thu, 2005-09-01 at 10:58, Guido van Rossum wrote: > > > [Reinhold Birkenfeld] > > > You'd have to enclose print arguments in parentheses. Of course, the > > > "trailing > > > comma" form would be lost. > > > > And good riddance! The print st

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

2005-09-01 Thread Barry Warsaw
On Thu, 2005-09-01 at 10:58, Guido van Rossum wrote: > [Reinhold Birkenfeld] > > You'd have to enclose print arguments in parentheses. Of course, the > > "trailing > > comma" form would be lost. > > And good riddance! The print statement harks back to ABC and even > (unvisual) Basic. Out with it

Re: [Python-Dev] Status of PEP 328

2005-09-01 Thread Guido van Rossum
It's been approved, but AFAIK still awaiting a patch. So yes, please help! On 9/1/05, Nicolas Fleury <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to know what is the status of PEP 328? Can absolute_import > be expected in 2.5? Any help needed? I'll be interested. > > Also, the content of

Re: [Python-Dev] Python 3 design principles

2005-09-01 Thread Guido van Rossum
On 9/1/05, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > I'm all for removing the cruft in python 3, and giving it a bit of a > spring clean, but please, please don't make it feel like a different > language otherwise the users will be deserting in droves (no-one likes > to be told that they've been

[Python-Dev] Status of PEP 328

2005-09-01 Thread Nicolas Fleury
Hi, I would like to know what is the status of PEP 328? Can absolute_import be expected in 2.5? Any help needed? I'll be interested. Also, the content of the PEP doesn't seem to be up-to-date with the status quo, since it is mentioned support in 2.4 for "from __future__ import absolute_impor

[Python-Dev] Replacement for print in Python 3.0

2005-09-01 Thread Guido van Rossum
[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] > > There's no way importing a module could add something th

Re: [Python-Dev] String views

2005-09-01 Thread Guido van Rossum
On 8/31/05, Greg Ewing <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > Ah, I forgot the data is part of the PyString object itself, not stored as a > > separate char* array. Without a char* in the object it's kind of hard to do > > views. > > That wouldn't be a problem if substrings

Re: [Python-Dev] String views

2005-09-01 Thread Michael Chermside
Tim Delaney writes: > One of the big disadvantages of string views is that they need to keep > the original object around, no matter how big it is. But in the case of > partition, much of the time the original string survives for at least a > similar period to the partitions. Why do you say that?

[Python-Dev] C coding experiment

2005-09-01 Thread Raymond Hettinger
If anyone wants a small, but interesting C project, let me know. The project does not require much familiarity with the CPython implementation; all that is needed are basic C coding skills and a puzzle solving mentality. The goal is to determine whether the setobject.c implementation would be i

Re: [Python-Dev] Python 3 design principles

2005-09-01 Thread Barry Warsaw
On Thu, 2005-09-01 at 05:54, Nick Coghlan wrote: > Oren Tirosh wrote: > > * Replacing print with write/writeln > > I still hope to see this change to "make print a builtin instead of a > statement". I'd hate to lose the one-line hello world example due to cruft > like "from sys import stdout". I

Re: [Python-Dev] python/dist/src/Lib/test test_re.py, 1.45.6.3, 1.45.6.4

2005-09-01 Thread A.M. Kuchling
On Wed, Aug 31, 2005 at 07:56:04PM -0400, Jim Jewett wrote: > What is the reasoning behind this? > > It seems to me that if a (passing) test is being added, maintenance releases > are the *most* important places to run them. In this case, it's because adding the test requires importing a new mod

Re: [Python-Dev] Proof of the pudding: str.partition()

2005-09-01 Thread Nick Coghlan
Charles Cazabon wrote: >>also, a Boolean positional argument is a really poor clue about its meaning, >>and it's easy to misremember the sense reversed. > > > I totally agree. I therefore borrowed the time machine and modified my > proposal to suggest it should be a keyword argument, not a posit

Re: [Python-Dev] Python 3 design principles

2005-09-01 Thread Nick Craig-Wood
On Thu, Sep 01, 2005 at 08:55:48AM +0200, Kay Schluehr wrote: > The idea of forking a language with a new release and thereby > deevaluating older code seems somewhat archaic to me. Or the other way > round: archaic materials and media like papyrus and scripture enabled > communication across cent

Re: [Python-Dev] Python 3 design principles

2005-09-01 Thread Nick Coghlan
Oren Tirosh wrote: > * Replacing print with write/writeln I still hope to see this change to "make print a builtin instead of a statement". I'd hate to lose the one-line hello world example due to cruft like "from sys import stdout". Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] |