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] Revising RE docs

2005-09-05 Thread Fredrik Lundh
Guido van Rossum wrote: I also notice that _compile() is needlessly written as a varargs function -- all its uses pass it exactly two arguments. that's because the function uses [1] the argument tuple as the cache key, and I wanted to make the cache hit path as fast as possible. (but that was

Re: [Python-Dev] Revising RE docs

2005-09-05 Thread Gareth McCaughan
Guido wrote: They *are* cached and there is no cost to using the functions instead of the methods unless you have so many regexps in your program that the cache is cleared (the limit is 100). Sure there is; the cost of looking them up in the cache. ... So in this (highly

Re: [Python-Dev] Revising RE docs

2005-09-05 Thread Fredrik Lundh
Am I the only who are getting mails from iextream at naver.com whenever I post to python-dev, btw? My Korean (?) isn't that good, so I'm not sure what they want... /F ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] Revising RE docs

2005-09-05 Thread Tim Peters
[Fredrik Lundh] Am I the only who are getting mails from iextream at naver.com whenever I post to python-dev, btw? My Korean (?) isn't that good, so I'm not sure what they want... Only thing I've seen from them is one post in the archives, on June 13:

Re: [Python-Dev] gdbinit problem

2005-09-05 Thread Guido van Rossum
On 9/4/05, Neal Norwitz [EMAIL PROTECTED] wrote: break in gdbinit is apparently does not break a loop, but rather sets a break point. I don't know how to hit the break within lineno with a simple test case. Debugging pychecker with a C extension (matplotlib) triggers it. The only way I

Re: [Python-Dev] string formatting options and removing basestring.__mod__ (WAS: Replacement for print in Python 3.0)

2005-09-05 Thread Gareth McCaughan
If people know of other languages that have a different approach to string formatting, it might be useful to see them. Common Lisp has something broadly C-like but bigger and hairier. It includes powerful-but-confusing looping and conditional features, letting you say things like (format t

[Python-Dev] Example for property violates Python is not a one pass compiler

2005-09-05 Thread Edward C. Jones
Here is an example from the Python Library Reference, Section 2.1 Built-in Functions: class C(object): def getx(self): return self.__x def setx(self, value): self.__x = value def delx(self): del self.__x x = property(getx, setx, delx, I'm the 'x' property.) It works. But if

Re: [Python-Dev] string formatting and i18n

2005-09-05 Thread Antoine Pitrou
Le lundi 05 septembre 2005 à 16:52 +0100, Gareth McCaughan a écrit : ... and should add: Of course it's usually seen as being about output more than about formatting, but in fact if you want to do what Python does with %, C with sprintf and Common Lisp with (format nil ...) then the Right

Re: [Python-Dev] Example for property violates Python is not a one pass compiler

2005-09-05 Thread Phillip J. Eby
At 12:04 PM 9/5/2005 -0400, Edward C. Jones wrote: Normally I can use any method of a class anywhere in the definition of the class. Not true. You can certainly use any method of a class in any *functions* or methods defined in the body of the class. But you can't use them in the body of the

Re: [Python-Dev] Example for property violates Python is not a onepass compiler

2005-09-05 Thread Fredrik Lundh
Edward C. Jones write: Here is an example from the Python Library Reference, Section 2.1 Built-in Functions: class C(object): def getx(self): return self.__x def setx(self, value): self.__x = value def delx(self): del self.__x x = property(getx, setx, delx, I'm the 'x'

Re: [Python-Dev] string formatting and i18n

2005-09-05 Thread Barry Warsaw
On Mon, 2005-09-05 at 12:07, Antoine Pitrou wrote: Uh, what about internationalization (i18n) ? In i18n you can't avoid the need for parameterized strings. For example I want to write : _(The file '%s' is read only) % filename not : _(The file) + ' + filename + ' + _(is read

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] string formatting and i18n

2005-09-05 Thread Gareth McCaughan
On Monday 2005-09-05 17:07, Antoine Pitrou wrote: Le lundi 05 septembre 2005 à 16:52 +0100, Gareth McCaughan a écrit : ... and should add: Of course it's usually seen as being about output more than about formatting, but in fact if you want to do what Python does with %, C with sprintf and

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] string formatting and i18n

2005-09-05 Thread François Pinard
[Barry Warsaw] Actually, this was part of the motivation behind PEP 292 and Template strings, because what you really want is named parameters, not positional parameters: 'The file $filename in directory $dir is read only' There are a few techniques for getting full i18n for Template

Re: [Python-Dev] string formatting and i18n

2005-09-05 Thread Barry Warsaw
On Mon, 2005-09-05 at 14:10, François Pinard wrote: The file %(filename)s in directory %(dir)s is read only % vars() is already usable. The need being already filled without Template strings, it could hardly be presented as a motivation for them. :-) Except that IME, %(var)s is an

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] String views

2005-09-05 Thread skip
Greg If a Python function is clearly wrapping a C function, one doesn't Greg expect to be able to pass strings with embedded NULs to it. Isn't that just floating an implementation detail up to the programmer (who may well not be POSIX- or Unix-aware)?

Re: [Python-Dev] gdbinit problem

2005-09-05 Thread skip
Neal The only way I could see to fix it was by setting a continue flag Neal and testing it. Does anyone know a better way to fix this Neal problem? Certainly looks reasonable until we figure out how (if at all) GDB's command language implements a break-like statement. Skip

Re: [Python-Dev] String views

2005-09-05 Thread Steve Holden
[EMAIL PROTECTED] wrote: Greg If a Python function is clearly wrapping a C function, one doesn't Greg expect to be able to pass strings with embedded NULs to it. Isn't that just floating an implementation detail up to the programmer (who may well not be POSIX- or Unix-aware)? As

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] gdbinit problem

2005-09-05 Thread Guido van Rossum
On 9/5/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Neal The only way I could see to fix it was by setting a continue flag Neal and testing it. Does anyone know a better way to fix this Neal problem? Certainly looks reasonable until we figure out how (if at all) GDB's