Re: [Python-3000] Reverse file iteration patch updated

2007-12-09 Thread Oleg Broytmann
for line in reversed(open(path)): > > print line > > If this involves hacking reversed() to give it special > knowledge of files, I'm not sure it's the best place > to put it. It adds a method __reversed__() to class io.TextIOWrapper: http://bugs.python.org/fi

Re: [Python-3000] Reverse file iteration patch updated

2007-12-09 Thread Gregory P. Smith
it doesn't. read the patch. it adds a __reversed__ method. http://bugs.python.org/file8902/reverse-file-iterator-20071209.diff On 12/9/07, Greg Ewing <[EMAIL PROTECTED]> wrote: > > Mark Russell wrote: > > I posted a patch (http://bugs.python.org/issue1677872) a while

Re: [Python-3000] Reverse file iteration patch updated

2007-12-09 Thread Greg Ewing
Mark Russell wrote: > I posted a patch (http://bugs.python.org/issue1677872) a while ago to > add support for reverse iteration through text files - i.e. making > this work: > > for line in reversed(open(path)): > print line If this involves hacking reversed() to give it speci

Re: [Python-3000] Reconsider repr(0.1) == '0.10000000000000001'

2007-12-09 Thread Terry Reedy
"Georg Brandl" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Terry Reedy schrieb: | > It seems your real problem is that repr() rather than str() is applied | > within collections. (I am not sure exactly why but suspect there is a | > reason.) | | Consider ["1, 2, 3"]. OK, but t

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-09 Thread Jim Jewett
On 12/9/07, Christian Heimes <[EMAIL PROTECTED]> wrote: > Jim Jewett wrote: > > Could you give me a use-case for post-import hooks *without* lazy imports? > This thread was started with perfect valid and good use case. We want to > apply ABCs to classes of optional modules like decimal and array w

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-09 Thread Christian Heimes
Jim Jewett wrote: > Could you give me a use-case for post-import hooks *without* lazy imports? This thread was started with perfect valid and good use case. We want to apply ABCs to classes of optional modules like decimal and array without loading the module or modifying the module. @imp.impo

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-09 Thread Jim Jewett
On 12/9/07, Christian Heimes <[EMAIL PROTECTED]> wrote: > The touch points between post import hooks and lazy imports > are minimal. Could you give me a use-case for post-import hooks *without* lazy imports? As nearly as I can tell, either (1) The module is already loaded (and the whole infras

Re: [Python-3000] Possible Duck Typing Problem in Python 2.5?

2007-12-09 Thread Greg Ewing
hashcollision wrote: > TypeError: can only concatenate list (not "instance") to list > > IMHO, this is a problem. Is it? If so, I suggest that it be fixed in python > 3000. I seem to remember this came up before, and was considered not to be something that needed changing. How would you decide

Re: [Python-3000] Possible Duck Typing Problem in Python 2.5?

2007-12-09 Thread Daniel Stutzbach
On Dec 9, 2007 3:21 PM, hashcollision <[EMAIL PROTECTED]> wrote: > From http://ivory.idyll.org/blog/dec-07/conversions.html: > > class X: > internal = [5,6,7,8] > def __getitem__(self, i): > return self.internal[i] > > x = X() > > l = [1,2,3] > print l + x > > fails with > > TypeEr

Re: [Python-3000] Possible Duck Typing Problem in Python 2.5?

2007-12-09 Thread Guilherme Polo
-- Forwarded message -- From: Guilherme Polo <[EMAIL PROTECTED]> Date: 09/12/2007 19:45 Subject: Re: [Python-3000] Possible Duck Typing Problem in Python 2.5? To: hashcollision <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 2007/12/9, hashcollision <[EMAIL PROTECTED]>: > From http://ivory.

[Python-3000] Reverse file iteration patch updated

2007-12-09 Thread Mark Russell
I posted a patch (http://bugs.python.org/issue1677872) a while ago to add support for reverse iteration through text files - i.e. making this work: for line in reversed(open(path)): print line It steps through the file backwards a line at a time, without reading the entire f

[Python-3000] Possible Duck Typing Problem in Python 2.5?

2007-12-09 Thread hashcollision
>From http://ivory.idyll.org/blog/dec-07/conversions.html: class X: internal = [5,6,7,8] def __getitem__(self, i): return self.internal[i] x = X() l = [1,2,3] print l + x fails with TypeError: can only concatenate list (not "instance") to list I tried: class X(list): interna

Re: [Python-3000] Is py3k branch still frozen?

2007-12-09 Thread Christian Heimes
[EMAIL PROTECTED] wrote: > Is the freeze for 3.0a2 still in place? I have a trivial docstring fix for > bytesobject.c. The 3.0a2 release is out and the branch is open again. Christian ___ Python-3000 mailing list Python-3000@python.org http://mail.pyth

[Python-3000] Is py3k branch still frozen?

2007-12-09 Thread skip
Is the freeze for 3.0a2 still in place? I have a trivial docstring fix for bytesobject.c. Skip ___ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/p

Re: [Python-3000] Reconsider repr(0.1) == '0.10000000000000001'

2007-12-09 Thread Gustavo Niemeyer
> Great! He also provides C code, in > http://www.cs.indiana.edu/~burger/fp/index.html FWIW: http://labix.org/python-nicefloat -- Gustavo Niemeyer http://niemeyer.net ___ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/l

Re: [Python-3000] Reconsider repr(0.1) == '0.10000000000000001'

2007-12-09 Thread Noam Raphael
Great! He also provides C code, in http://www.cs.indiana.edu/~burger/fp/index.html The license says: "All software (c) 1996 Robert G. Burger. Permission is hereby granted, free of charge, to any person obtaining a copy of this software, to deal in the software without restriction, including withou

Re: [Python-3000] Interest in PEP for callbacks on module import

2007-12-09 Thread Christian Heimes
Phillip J. Eby wrote: > Thinking that they can, and actually producing a tested > implementation of one that does not, in fact, conflict with the > implementation of the other, are two different things. > > My concern is that I doubt that you can implement the post-import > hook without in the

Re: [Python-3000] Reconsider repr(0.1) == '0.10000000000000001'

2007-12-09 Thread Georg Brandl
Terry Reedy schrieb: > "Noam Raphael" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > | My use case is data manipulation in the interactive shell - You could always override sys.displayhook in order to handle floats differently. > It seems your real problem is that repr() rather

Re: [Python-3000] Reconsider repr(0.1) == '0.10000000000000001'

2007-12-09 Thread Marcin ‘Qrczak’ Kowalczyk
Dnia 09-12-2007, N o godzinie 10:33 +0200, Noam Raphael pisze: > I think that the reason for the long representation is that it uses a > simple algorithm that makes "eval(repr(f)) == f" always true. However, > why not use another, a bit more complex, algorithm, which will still > preserve "eval(re

Re: [Python-3000] Reconsider repr(0.1) == '0.10000000000000001'

2007-12-09 Thread Terry Reedy
"Noam Raphael" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | My use case is data manipulation in the interactive shell - When doing things other than add and subtract, one soon gets floats that are no longer such 'even' decimals, even if the input is. | Many times I have float

Re: [Python-3000] Reconsider repr(0.1) == '0.10000000000000001'

2007-12-09 Thread Martin v. Löwis
> I would like to re-raise the issue of float repr() -- making repr(1.1) > == '1.1' instead of '1.1001'. Can you propose an algorithm that meets your needs, and still has the property of unambiguously identifying the true floating point number? It's (perhaps) easy to request this, but

[Python-3000] Reconsider repr(0.1) == '0.10000000000000001'

2007-12-09 Thread Noam Raphael
Hello, I would like to re-raise the issue of float repr() -- making repr(1.1) == '1.1' instead of '1.1001'. My use case is data manipulation in the interactive shell - an extremely powerful tool which, it seems, not so many people use. Many times I have float data. I think that you'll