Re: [Python-3000] dbm package creation

2008-05-27 Thread Guido van Rossum
On Sun, May 25, 2008 at 3:08 PM, Brett Cannon <[EMAIL PROTECTED]> wrote: > On Sun, May 25, 2008 at 12:21 PM, Georg Brandl <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I'll handle the PEP 3108 dbm package if nobody else is already at it. >> > > I know I have not started the work. > >> Two questions thoug

Re: [Python-3000] str(container) calls repr() (was: PEP 3138)

2008-05-27 Thread Guido van Rossum
On Tue, May 27, 2008 at 1:36 AM, Oleg Broytmann <[EMAIL PROTECTED]> wrote: > On Tue, May 27, 2008 at 06:13:39PM +1000, Nick Coghlan wrote: >> str([1, 2, 3]), str(list("123")) and str(["1, 2, 3"]) should all produce >> distinctive output: calling repr() on container contents achieves this, >> callin

Re: [Python-3000] PEP 3138- String representation in Python 3000

2008-05-27 Thread Jim Jewett
On 5/26/08, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Jim Jewett wrote: > > The problem is classes where str(x) != repr(x), and how they get > > messed up when a container holding (one of their) instances is > > printed. > This is NOT a bug, since str([1, 2, 3]) and str(list("123")) SHOULD produc

Re: [Python-3000] PEP 3138- String representation in Python 3000

2008-05-27 Thread Jim Jewett
On 5/26/08, Stephen J. Turnbull <[EMAIL PROTECTED]> wrote: > Jim Jewett writes: > > The only reason for this change is that __repr__ gets used when > > __str__ *should* be used instead. > That's not what the advocates say. I still haven't seen a use case where it *should* be using repr *and*

Re: [Python-3000] PEP 3138- String representation in Python 3000

2008-05-27 Thread Jim Jewett
On 5/27/08, Adam Olsen <[EMAIL PROTECTED]> wrote: > On Mon, May 26, 2008 at 8:13 PM, Jim Jewett <[EMAIL PROTECTED]> wrote: > > The problem is classes where str(x) != repr(x), and how they get > > messed up when a container holding (one of their) instances is > > printed. > class A: > >>

Re: [Python-3000] PEP 3138- String representation in Python 3000

2008-05-27 Thread Jim Jewett
On 5/27/08, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: > On 2008-05-27 05:02, Stephen J. Turnbull wrote: > > ... repr() Spanish and Chinese users are going to feel more or less > > differently from Americans about which characters should be escaped. > I'm not sure that's always the case, but users

Re: [Python-3000] [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Guido van Rossum
[+python-3000] On Tue, May 27, 2008 at 12:32 PM, Armin Ronacher <[EMAIL PROTECTED]> wrote: > Strings are currently iterable and it was stated multiple times that this is a > good idea and shouldn't change. While I still don't think that that's a good > idea I would like to propose a solution for

Re: [Python-3000] UPDATED: PEP 3138- String representation in Python 3000

2008-05-27 Thread Jim Jewett
On 5/26/08, Nick Coghlan <[EMAIL PROTECTED]> wrote: > > The problem isn't that I want to be able to write code that acts the > > old way; the problem is that I want to ensure all code running on my > > system acts the old way. > This is for Py3k - you'll be lucky if your old code runs at all, let

Re: [Python-3000] PEP 3138- String representation in Python 3000

2008-05-27 Thread Jeffrey Yasskin
On Tue, May 27, 2008 at 2:33 PM, Jim Jewett <[EMAIL PROTECTED]> wrote: > I say that repr should (insetad) start recognizing when it was called > in place of __str__, and should revert back to __str__ when it > recurses down to the next level. That sounds like a PEP you should write, which, if acce

Re: [Python-3000] PEP 3138- String representation in Python 3000

2008-05-27 Thread Oleg Broytmann
On Tue, May 27, 2008 at 03:04:02PM -0500, Jeffrey Yasskin wrote: > On Tue, May 27, 2008 at 2:33 PM, Jim Jewett <[EMAIL PROTECTED]> wrote: > > I say that repr should (insetad) start recognizing when it was called > > in place of __str__, and should revert back to __str__ when it > > recurses down to

Re: [Python-3000] [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Benji York
On Tue, May 27, 2008 at 3:42 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > [+python-3000] > > On Tue, May 27, 2008 at 12:32 PM, Armin Ronacher > <[EMAIL PROTECTED]> wrote: >> Basically *the* problematic situation with iterable strings is something like >> a `flatten` function that flattens out

Re: [Python-3000] UPDATED: PEP 3138- String representation in Python 3000

2008-05-27 Thread Adam Olsen
On Tue, May 27, 2008 at 2:03 PM, Jim Jewett <[EMAIL PROTECTED]> wrote: > On 5/26/08, Nick Coghlan <[EMAIL PROTECTED]> wrote: >> > The problem isn't that I want to be able to write code that acts the >> > old way; the problem is that I want to ensure all code running on my >> > system acts the old w

[Python-3000] how to deal with compatibility problems (example: turtle module)

2008-05-27 Thread Gregor Lingl
Hi, when doing some final checking of the new turtle module I ran into the following problem, which I'd like to discuss with the intention to clarify how to handle problems that result more or less from suboptimal design decisions of the module to replace.: (1) As requested I added an __all__ va

Re: [Python-3000] dbm package creation

2008-05-27 Thread Georg Brandl
Guido van Rossum schrieb: On Sun, May 25, 2008 at 3:08 PM, Brett Cannon <[EMAIL PROTECTED]> wrote: On Sun, May 25, 2008 at 12:21 PM, Georg Brandl <[EMAIL PROTECTED]> wrote: Hi, I'll handle the PEP 3108 dbm package if nobody else is already at it. I know I have not started the work. Two qu

Re: [Python-3000] how to deal with compatibility problems (example: turtle module)

2008-05-27 Thread Guido van Rossum
The old turtle.py explicitly says from math import * # Also for export so I think it's desirable to keep this behavior. My intent with that line was that an absolute beginner could put "from turtle import *" in their interactive session and be able to use both the turtle code and the high-school

Re: [Python-3000] dbm package creation

2008-05-27 Thread Guido van Rossum
On Tue, May 27, 2008 at 1:48 PM, Georg Brandl <[EMAIL PROTECTED]> wrote: > Guido van Rossum schrieb: >> >> On Sun, May 25, 2008 at 3:08 PM, Brett Cannon <[EMAIL PROTECTED]> wrote: >>> >>> On Sun, May 25, 2008 at 12:21 PM, Georg Brandl <[EMAIL PROTECTED]> wrote: Hi, I'll handle t

Re: [Python-3000] dbm package creation

2008-05-27 Thread Georg Brandl
Guido van Rossum schrieb: I'm not sure I disagree. I see the return value as an enum, only one use for which is to import it. (If you wanted to just use the module, why not use anydbm?) I'd prefer to keep the return strings the same (no 'dbm.' prefix) and fix the code that uses whichdb. So add

Re: [Python-3000] dbm package creation

2008-05-27 Thread Guido van Rossum
On Tue, May 27, 2008 at 2:16 PM, Georg Brandl <[EMAIL PROTECTED]> wrote: > Guido van Rossum schrieb: > I'm not sure I disagree. I see the return value as an enum, only one use for which is to import it. (If you wanted to just use the module, why not use anydbm?) I'd prefer to keep th

Re: [Python-3000] dbm package creation

2008-05-27 Thread Georg Brandl
Guido van Rossum schrieb: Or is there an expected future use case where the returned value would be something in a *different* package? There was in the past, with the now-defunct bsddb185 module which was not used by anydbm. Returning a module object would seem the least attractive version

Re: [Python-3000] how to deal with compatibility problems (example: turtle module)

2008-05-27 Thread Gregor Lingl
Guido van Rossum schrieb: The old turtle.py explicitly says from math import * # Also for export so I think it's desirable to keep this behavior. My intent with that line was that an absolute beginner could put "from turtle import *" in their interactive session and be able to use both the tu

Re: [Python-3000] Single buffer implied in new buffer protocol?

2008-05-27 Thread Travis Oliphant
Stefan Behnel wrote: Hi, while implementing Py_buffer support in Cython, I noticed (the hard way, throught a segfault), that the buffer pointer passed into getbuffer() can be NULL, e.g. when calling memoryview.tobytes(). According to PEP 3118 (first paragraph below the getbuffer() signature), th

Re: [Python-3000] dbm package creation

2008-05-27 Thread Guido van Rossum
On Tue, May 27, 2008 at 2:37 PM, Georg Brandl <[EMAIL PROTECTED]> wrote: > Guido van Rossum schrieb: > >> Or is there an expected future use case where the returned value would >> be something in a *different* package? > > There was in the past, with the now-defunct bsddb185 module

Re: [Python-3000] how to deal with compatibility problems (example: turtle module)

2008-05-27 Thread Guido van Rossum
In the light of that, I'm not opposed to relaxing the 100% compatibility requirement. On Tue, May 27, 2008 at 2:40 PM, Gregor Lingl <[EMAIL PROTECTED]> wrote: > > > Guido van Rossum schrieb: >> >> The old turtle.py explicitly says >> >> from math import * # Also for export >> >> so I think it's de

Re: [Python-3000] [Python-Dev] Iterable String Redux (aka String ABC)

2008-05-27 Thread Jim Jewett
On 5/27/08, Benji York wrote: > Guido van Rossum wrote: > > Armin Ronacher wrote: > >> Basically *the* problematic situation with iterable strings is something > >> like > >> a `flatten` function that flattens out every iterable object except of > strings. > > I'm not against this, but so far

Re: [Python-3000] [Python-Dev] Iterable String Redux (aka StringABC)

2008-05-27 Thread Raymond Hettinger
"Jim Jewett" It isn't really stringiness that matters, it is that you have to terminate even though you still have an iterable container. Well said. Guido had at least a start in Searchable, back when ABC were still in the sandbox: Have to disagree here. An object cannot know in general w

Re: [Python-3000] PEP 3138- String representation in Python 3000

2008-05-27 Thread Nick Coghlan
Jim Jewett wrote: So I suggest that he or she use str, rather than repr -- and that we fix containers to make this possible. And hope that every other author of a Python container class on the planet does the same thing? Recursing downwards with str() instead of repr() will break as soon as

Re: [Python-3000] UPDATED: PEP 3138- String representation in Python 3000

2008-05-27 Thread Nick Coghlan
Blake Winton wrote: Nick Coghlan wrote: While it could be argued that if you want unambiguous output you should be invoking repr() on the container instead of str(), I'm still seeing many more downsides than upsides to the idea of making str() on the builtin containers display their contents w

Re: [Python-3000] PEP 3138- String representation in Python 3000

2008-05-27 Thread Greg Ewing
M.-A. Lemburg wrote: AFAIK, eval(repr(obj)) is no longer a requirement... simply because it has always only worked for a small subset of objects and in reality, you wouldn't want to call eval() on anything too often due to the security implications. Yes, I actually think that sentence in the d

Re: [Python-3000] UPDATED: PEP 3138- String representation in Python 3000

2008-05-27 Thread Jim Jewett
On 5/27/08, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Blake Winton wrote: > > But which downsides do you see that aren't solved by the use of repr to > get unambiguous output? > The fact that calling str() on containers has been unambiguous for years. > All I'm saying is that no compelling use c

Re: [Python-3000] UPDATED: PEP 3138- String representation in Python 3000

2008-05-27 Thread Greg Ewing
Blake Winton wrote: Seriously, I can write: >>> print 1, "1", Decimal("1") and get as my output: 1 1 1 Yes, but you've explicitly told it to print that, so presumably it's what you want in that case. Equally, you need to be explicit about how you want a list printed. -- Greg ___

Re: [Python-3000] UPDATED: PEP 3138- String representation in Python 3000

2008-05-27 Thread Jim Jewett
On 5/27/08, Greg Ewing <[EMAIL PROTECTED]> wrote: > Blake Winton wrote: > > Seriously, I can write: > > >>> print 1, "1", Decimal("1") > > and get as my output: > > 1 1 1 > Yes, but you've explicitly told it to print that, > so presumably it's what you want in that case. > Equally, you need

Re: [Python-3000] PEP 3138- String representation in Python 3000

2008-05-27 Thread Greg Ewing
Jim Jewett wrote: PEP 3138 says that repr should start printing unicode glyphs. I say that repr should (insetad) start recognizing when it was called in place of __str__, and should revert back to __str__ when it recurses down to the next level. But we *don't* all agree that the only case whe

Re: [Python-3000] Single buffer implied in new buffer protocol?

2008-05-27 Thread Greg Ewing
Travis Oliphant wrote: Obviously, if you haven't provided a Py_buffer structure to fill in, then you are only asking to lock the object's buffer from other access. What's the use case for that? Why would you ever want to lock an object if you don't intend to access it? BTW, I seem to remember

Re: [Python-3000] UPDATED: PEP 3138- String representation in Python 3000

2008-05-27 Thread Greg Ewing
Jim Jewett wrote: Again, what is the advantage of having str(x) be redundant to repr(x) in the case of containers? I think you're misrepresenting the situation when you describe it that way. Guido didn't sit down and think "I know, let's make str(lst) do the same as repr(lst)." He thought "It'

[Python-3000] Proposal to add __str__ method to iterables.

2008-05-27 Thread Carl Johnson
Proposal to add __str__ method to iterables: Proposed behavior of the __str__ method for iterables is that it returns the result of "".join(str(i) for i in self). Justification: Notice this difference in the behavior of filter* and a list comprehension: >>> filter(lambda c: c!="a", "abra