Re: [Python-Dev] A Horrible Inconsistency
On Fri, May 26, 2006, Fredrik Lundh wrote: > > and while we're at it, let's fix this: > > >>> 0.66 * (1, 2, 3) > (1, 2) > > and maybe even this > > >>> 0.5 * (1, 2, 3) > (1, 1) > > but I guess the latter one might need a pronunciation. This should certainly get fixed in 3.0 thanks to __index__ -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "I saw `cout' being shifted "Hello world" times to the left and stopped right there." --Steve Gonedes ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
On 5/26/06, Facundo Batista <[EMAIL PROTECTED]> wrote: > I think that we can do one of the following, when we found "-1 * (1, 2, 3)": > > - Treat -1 as 0 and return an empty tuple (actual behavior). > - Treat the negative as a reverser, so we get back (3, 2, 1). > - Raise an error. No, no, no. The important invariant is that n * seq is loop(seq)[:n*len(seq)] where loop(seq) is an endless loop of the elements of seq. So obviously, if n is negative, the result should be an infinite sequence that's == to loop(seq). -j ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
2006/5/26, Steven Bethard <[EMAIL PROTECTED]>: > On 5/26/06, Facundo Batista <[EMAIL PROTECTED]> wrote: > > All this different ways enforce my vote: we should get an error... > ... > But if this change goes in, I want a big "we're breaking backwards > incompatibility" message somewhere. I say if you really want an > exception raised for these cases, ask for the behavior change in > Python 3000. All it would give us in Python 2.X is a bunch of broken > code. Of course that this change can not be made in 2.x. Regards, -- .Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
On 5/26/06, Facundo Batista <[EMAIL PROTECTED]> wrote: > All this different ways enforce my vote: we should get an error... Perhaps you missed Tim's post, so here's a few lines of my own code that I know would break: padding = [None] * (self.width - len(leaves)) left_padding = [None] * (self.left_width - len(left_window)) right_padding = [None] * (self.right_width - len(right_window)) Sure, I could write these as: padding = [None] * max(0, self.width - len(leaves)) left_padding = [None] * max(0, self.left_width - len(left_window)) right_padding = [None] * max(0, self.right_width - len(right_window)) But if this change goes in, I want a big "we're breaking backwards incompatibility" message somewhere. I say if you really want an exception raised for these cases, ask for the behavior change in Python 3000. All it would give us in Python 2.X is a bunch of broken code. STeVe -- Grammar am for people who can't think for myself. --- Bucky Katt, Get Fuzzy ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
2006/5/26, Fred L. Drake, Jr. <[EMAIL PROTECTED]>: > Even better: > > "123"*-1 > > We'd get to explain: > > - what the "*-" operator is all about, and > > - why we'd use it with a string and an int. > > I see possibilities here. :-) All this different ways enforce my vote: we should get an error... Regards, -- .Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Fred L. Drake, Jr. wrote: > Even better: > > "123"*-1 > > We'd get to explain: > > - what the "*-" operator is all about, and > > - why we'd use it with a string and an int. > > I see possibilities here. :-) the infamous "*-" clear operator? who snuck that one into python? ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Fred> I see possibilities here. :-) Fred appears to be looking for more job security. ;-) Skip ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Fredrik Lundh wrote: > Sean Reifschneider wrote: > >>> - Treat the negative as a reverser, so we get back (3, 2, 1). >> >> Then we could get: >> >>>>> print -123 >>321 >> >> Yay! > > and while we're at it, let's fix this: > > >>> 0.66 * (1, 2, 3) > (1, 2) > > and maybe even this > > >>> 0.5 * (1, 2, 3) > (1, 1) > > but I guess the latter one might need a pronunciation. No, no, no! Floating point is so inaccurate! It has to be >>> Decimal("0.5") * (1, 2, 3) (1, Decimal("1")) Georg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
On Friday 26 May 2006 11:50, Georg Brandl wrote: > This is actually a nice idea, because it's even a more nonintuitive > answer for Python newbies posting to c.l.py asking how to reverse > a string Even better: "123"*-1 We'd get to explain: - what the "*-" operator is all about, and - why we'd use it with a string and an int. I see possibilities here. :-) -Fred -- Fred L. Drake, Jr. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Sean Reifschneider wrote: >> - Treat the negative as a reverser, so we get back (3, 2, 1). > > Then we could get: > >>>> print -123 >321 > > Yay! and while we're at it, let's fix this: >>> 0.66 * (1, 2, 3) (1, 2) and maybe even this >>> 0.5 * (1, 2, 3) (1, 1) but I guess the latter one might need a pronunciation. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Facundo Batista wrote: > 2006/5/26, Sean Reifschneider <[EMAIL PROTECTED]>: > >> On Fri, May 26, 2006 at 12:37:02PM -0300, Facundo Batista wrote: >> >- Treat the negative as a reverser, so we get back (3, 2, 1). >> >> Then we could get: >> >>>>> print -123 >>321 > > An integer is NOT a sequence. > > OTOH, that should be consistent to > -1 * "123" > "321" This is actually a nice idea, because it's even a more nonintuitive answer for Python newbies posting to c.l.py asking how to reverse a string Georg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
2006/5/26, Sean Reifschneider <[EMAIL PROTECTED]>: > On Fri, May 26, 2006 at 12:37:02PM -0300, Facundo Batista wrote: > >- Treat the negative as a reverser, so we get back (3, 2, 1). > > Then we could get: > >>>> print -123 >321 An integer is NOT a sequence. OTOH, that should be consistent to >>> -1 * "123" "321" And remember I voted for returning an error, ;) -- .Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
On Fri, May 26, 2006 at 12:37:02PM -0300, Facundo Batista wrote: >- Treat the negative as a reverser, so we get back (3, 2, 1). Then we could get: >>> print -123 321 Yay! Thanks, Sean -- Sometimes it pays to stay in bed on Monday, rather than spending the rest of the week debugging Monday's code. -- Christopher Thompson Sean Reifschneider, Member of Technical Staff <[EMAIL PROTECTED]> tummy.com, ltd. - Linux Consulting since 1995: Ask me about High Availability ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
2006/5/25, Fredrik Lundh <[EMAIL PROTECTED]>: > >>> -1 * (1, 2, 3) > () > >>> -(1, 2, 3) > Traceback (most recent call last): >File "", line 1, in > TypeError: bad operand type for unary - > > We Really Need To Fix This! I don't see here an inconsistency. The operator "*" is not a multiplier as in math, it's more a "repeater", so math multiplier attributes don't apply here. There's no concept like "negative tuple" or "positive tuple", so the second example is clearly an error. Regarding the first line, in the docs expresely says "Values of n less than 0 are treated as 0". I think that we can do one of the following, when we found "-1 * (1, 2, 3)": - Treat -1 as 0 and return an empty tuple (actual behavior). - Treat the negative as a reverser, so we get back (3, 2, 1). - Raise an error. Personally, +0 on the third. Regards, -- .Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Greg Ewing wrote: > Steve Holden wrote: > > >>In actual fact the effbot has lately found itself so permeated with >>Windows that it has become constituionally incapable of using a forward >>slash. Don't know what's with the square brackets though ... > > > I was thinking maybe that message had resulted from > a Windows and a VMS port of the effbot that got > mixed together somehow... > That would be interesting: if we start to see semicolons in the sig strings we'll know which version of the bot is mailing. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Steve Holden wrote: > In actual fact the effbot has lately found itself so permeated with > Windows that it has become constituionally incapable of using a forward > slash. Don't know what's with the square brackets though ... I was thinking maybe that message had resulted from a Windows and a VMS port of the effbot that got mixed together somehow... -- Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Georg Brandl wrote: > Martin v. Löwis wrote: >> Fredrik Lundh wrote: >>> >>> -1 * (1, 2, 3) >>> () >>> >>> -(1, 2, 3) >>> Traceback (most recent call last): >>>File "", line 1, in >>> TypeError: bad operand type for unary - >>> >>> We Really Need To Fix This! >> >> I can't find this inconsistency horrible. >> >> py> +"Hello" >> Traceback (most recent call last): >> File "", line 1, in ? >> TypeError: bad operand type for unary + >> py> +1*"Hello" >> 'Hello' > > Don't tell me that! I was actually working on a patch right now... Since I've already been bombarded with questions by some fellow Germans (which once again prove that they've got no sense of humour at all ;): this was a joke. georG ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Tim Peters wrote: > [Raymond Hettinger] > ... >> Also, I'm not clear on the rationale for transforming negative >> repetition counts to zero instead of raising an exception. > > There are natural use cases. Here's one: you have a string and want > to right-justify it to 80 columns with blanks if it's shorter than 80. > > s = " " * (80 - len(s)) + s > > does the right thing in all cases, because the blank repetition > gracefully collapses to an empty string whenever len(s) >= 80. I've > used that (and variants thereof) dozens of times. Then again, I don't > believe I've ever used the "integer * sequence" form (i.e., with the > integer on the left). I originally brought that up because decimal.py uses it. (try to translate this to C code...) Georg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Fredrik Lundh wrote: > Guido van Rossum wrote: > > >>>We Really Need To Fix This! >>> >>>[\F] >> >>Doesn't the real effbot have /F as sig? > > > yeah, we've had some trouble with fake bots lately. I mean, there's a > timbot posting to this thread, but I know for sure that the real Tim got > tired of hacking on Python earlier tonight, and retired to his hotel > room. too much silica mud, I suppose. > In actual fact the effbot has lately found itself so permeated with Windows that it has become constituionally incapable of using a forward slash. Don't know what's with the square brackets though ... regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Love me, love my blog http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Guido van Rossum wrote: >> We Really Need To Fix This! >> >> [\F] > > Doesn't the real effbot have /F as sig? yeah, we've had some trouble with fake bots lately. I mean, there's a timbot posting to this thread, but I know for sure that the real Tim got tired of hacking on Python earlier tonight, and retired to his hotel room. too much silica mud, I suppose. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
[Raymond Hettinger] ... > Also, I'm not clear on the rationale for transforming negative > repetition counts to zero instead of raising an exception. There are natural use cases. Here's one: you have a string and want to right-justify it to 80 columns with blanks if it's shorter than 80. s = " " * (80 - len(s)) + s does the right thing in all cases, because the blank repetition gracefully collapses to an empty string whenever len(s) >= 80. I've used that (and variants thereof) dozens of times. Then again, I don't believe I've ever used the "integer * sequence" form (i.e., with the integer on the left). ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
On 5/25/06, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > Fredrik Lundh wrote: > > > >>> -1 * (1, 2, 3) > >() > > >>> -(1, 2, 3) > >Traceback (most recent call last): > > File "", line 1, in > >TypeError: bad operand type for unary - > > > >We Really Need To Fix This! > > > > > > The second one doesn't bug me. Unary minus on a sequence is meaningless. > > The first is a bit odd. When using the * operator for sequence > repetition, I don't expect it to have the same commutative property as > multiplication. IOW, "seq * n" makes sense but "n * seq" is a bit > weird. Also, I'm not clear on the rationale for transforming negative > repetition counts to zero instead of raising an exception. OTOH, > neither of these has EVER been an issue for me or anyone I know. It would be very strange if n*s didn't return the same thing as s*n. In fact, I can't even decide which one feels more natural! As to truncation of 0, that's debatable but can't be fixed until py3k -- surely lots of code (perhaps accidentally) depends on it. Still unclear which one \F wanted fixed... -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
[Fredrik] > >>> -1 * (1, 2, 3) > () > >>> -(1, 2, 3) > Traceback (most recent call last): >File "", line 1, in > TypeError: bad operand type for unary - > > We Really Need To Fix This! What's broken? It's generally true that n*s == s*n == empty_container_of_type_type(s) whenever s is a sequence and n is an integer <= 0. The above is just an instance of that. See footnote 2 in Library Ref section 2.3.6 Sequence Types. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Fredrik Lundh wrote: > >>> -1 * (1, 2, 3) >() > >>> -(1, 2, 3) >Traceback (most recent call last): > File "", line 1, in >TypeError: bad operand type for unary - > >We Really Need To Fix This! > > The second one doesn't bug me. Unary minus on a sequence is meaningless. The first is a bit odd. When using the * operator for sequence repetition, I don't expect it to have the same commutative property as multiplication. IOW, "seq * n" makes sense but "n * seq" is a bit weird. Also, I'm not clear on the rationale for transforming negative repetition counts to zero instead of raising an exception. OTOH, neither of these has EVER been an issue for me or anyone I know. Raymond ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
On Thu, May 25, 2006 at 09:06:49PM +, Georg Brandl wrote: >Don't tell me that! I was actually working on a patch right now... While undoubtedly a performance patch, it wasn't on the list of tasks to do today. You risk Steve's wrath! Thanks, Sean -- In the end, we will remember not the words of our enemies, but the silence of our friends. -- Martin Luther King Jr. Sean Reifschneider, Member of Technical Staff <[EMAIL PROTECTED]> tummy.com, ltd. - Linux Consulting since 1995: Ask me about High Availability ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Ronald Oussoren wrote: > I don't know which one Fredrik thinks is wrong, but I think the result > of -1*(1,2,3) is very surprising. I'd expect an exception here. I agree, but this has nothing to do with whether or not the unary - is supported. Regards, Martin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
On 25-mei-2006, at 23:04, Martin v. Löwis wrote: > Fredrik Lundh wrote: > -1 * (1, 2, 3) >> () > -(1, 2, 3) >> Traceback (most recent call last): >>File "", line 1, in >> TypeError: bad operand type for unary - >> >> We Really Need To Fix This! > > I can't find this inconsistency horrible. > > py> +"Hello" > Traceback (most recent call last): > File "", line 1, in ? > TypeError: bad operand type for unary + > py> +1*"Hello" > 'Hello' I don't know which one Fredrik thinks is wrong, but I think the result of -1*(1,2,3) is very surprising. I'd expect an exception here. Ronald > > Regards, > Martin > ___ > Python-Dev mailing list > Python-Dev@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/ > ronaldoussoren%40mac.com ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
You're joking right? On 5/25/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >>> -1 * (1, 2, 3) > () > >>> -(1, 2, 3) > Traceback (most recent call last): >File "", line 1, in > TypeError: bad operand type for unary - > > We Really Need To Fix This! > > [\F] Doesn't the real effbot have /F as sig? -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Martin v. Löwis wrote: > Fredrik Lundh wrote: >> >>> -1 * (1, 2, 3) >> () >> >>> -(1, 2, 3) >> Traceback (most recent call last): >>File "", line 1, in >> TypeError: bad operand type for unary - >> >> We Really Need To Fix This! > > I can't find this inconsistency horrible. > > py> +"Hello" > Traceback (most recent call last): > File "", line 1, in ? > TypeError: bad operand type for unary + > py> +1*"Hello" > 'Hello' Don't tell me that! I was actually working on a patch right now... Georg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] A Horrible Inconsistency
Fredrik Lundh wrote: > >>> -1 * (1, 2, 3) > () > >>> -(1, 2, 3) > Traceback (most recent call last): >File "", line 1, in > TypeError: bad operand type for unary - > > We Really Need To Fix This! I can't find this inconsistency horrible. py> +"Hello" Traceback (most recent call last): File "", line 1, in ? TypeError: bad operand type for unary + py> +1*"Hello" 'Hello' Regards, Martin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] A Horrible Inconsistency
>>> -1 * (1, 2, 3) () >>> -(1, 2, 3) Traceback (most recent call last): File "", line 1, in TypeError: bad operand type for unary - We Really Need To Fix This! [\F] ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com