Re: Python is not bad ;-)

2015-05-02 Thread Gregory Ewing
Steven D'Aprano wrote: People coming from functional languages like Lisp and Haskell often say that, but how many recursive algorithms naturally take a tail-call form? Not that many. And the ones that do tend to be the ones that are better expressed iteratively in Python. So Python doesn't rea

Re: Python is not bad ;-)

2015-05-02 Thread Cecil Westerhof
Op Friday 1 May 2015 09:03 CEST schreef Steven D'Aprano: > On Thu, 30 Apr 2015 09:30 pm, Cecil Westerhof wrote: > >> Tail recursion would nice to have also. > > People coming from functional languages like Lisp and Haskell often > say that, but how many recursive algorithms naturally take a > tail

Re: Fast way of extracting files from various folders

2015-05-02 Thread subhabrata . banerji
On Friday, May 1, 2015 at 5:58:50 PM UTC+5:30, subhabrat...@gmail.com wrote: > Dear Group, > > I have several millions of documents in several folders and subfolders in my > machine. > I tried to write a script as follows, to extract all the .doc files and to > convert them in text, but it seems

Re: GAE environment differences

2015-05-02 Thread Kev Dwyer
Robin Becker wrote: > On 01/05/2015 13:15, Chris Angelico wrote: >> On Fri, May 1, 2015 at 8:29 PM, Robin Becker wrote: >> >> >> Best thing to do is to ask the user to post the complete traceback. >> You might need to use "import os.path" but normally I would expect >> that not to be an issue. >

Re: Python is not bad ;-)

2015-05-02 Thread Marko Rauhamaa
Cecil Westerhof : > I find factorial a lot cleaner code as factorial_iterative, so here > tail recursion would be beneficial. I would just call math.factorial() and be done with it. Note: Scheme is my favorite language and I use tail recursion all the time. I also think eliminating tail recursion

Re: Fast way of extracting files from various folders

2015-05-02 Thread Peter Otten
subhabrata.bane...@gmail.com wrote: > I have several millions of documents in several folders and subfolders in > my machine. I tried to write a script as follows, to extract all the .doc > files and to convert them in text, but it seems it is taking too much of > time. > > import os > from fnmat

Re: convert pdf to excel xls file

2015-05-02 Thread jaronstreak
This is a very common problem when we need to convert excel files to pdf format. I have faced this problem many time. Because of my job nature i always need to convert many excel sheets because i could not send them to clients directly. It always took a long time to convert them manually. Then

Re: Python is not bad ;-)

2015-05-02 Thread Chris Angelico
On Sat, May 2, 2015 at 7:10 PM, Marko Rauhamaa wrote: > Note: Scheme is my favorite language and I use tail recursion all the > time. I also think eliminating tail recursion is such a low-hanging > fruit that even CPython should just pick it. However, I wouldn't use the > fibonacci sequence to jus

Re: Python is not bad ;-)

2015-05-02 Thread Marko Rauhamaa
Chris Angelico : > Guido is against anything that disrupts tracebacks, and optimizing > tail recursion while maintaining traceback integrity is rather harder. Tail recursion could be suppressed during debugging. Optimized code can play all kinds of non-obvious tricks with the execution frame. >

Re: Python is not bad ;-)

2015-05-02 Thread Cecil Westerhof
Op Saturday 2 May 2015 10:26 CEST schreef Cecil Westerhof: > Op Friday 1 May 2015 09:03 CEST schreef Steven D'Aprano: > >> On Thu, 30 Apr 2015 09:30 pm, Cecil Westerhof wrote: >> >>> Tail recursion would nice to have also. >> >> People coming from functional languages like Lisp and Haskell often >

Re: Python is not bad ;-)

2015-05-02 Thread Dave Angel
On 05/02/2015 05:58 AM, Marko Rauhamaa wrote: Chris Angelico : Guido is against anything that disrupts tracebacks, and optimizing tail recursion while maintaining traceback integrity is rather harder. Tail recursion could be suppressed during debugging. Optimized code can play all kinds of no

Re: Python is not bad ;-)

2015-05-02 Thread Dave Angel
On 05/02/2015 05:33 AM, Cecil Westerhof wrote: Please check your email settings. Your messages that you type seem to be indented properly, but those that are quoting earlier messages (even your own) are not. See below. I suspect there's some problem with how your email program processes htm

Re: Python is not bad ;-)

2015-05-02 Thread Chris Angelico
On Sat, May 2, 2015 at 8:22 PM, Dave Angel wrote: > On 05/02/2015 05:58 AM, Marko Rauhamaa wrote: >> >> Chris Angelico : >> >>> Guido is against anything that disrupts tracebacks, and optimizing >>> tail recursion while maintaining traceback integrity is rather harder. >> >> >> Tail recursion coul

Re: Fast way of extracting files from various folders

2015-05-02 Thread subhabrata . banerji
On Saturday, May 2, 2015 at 2:52:32 PM UTC+5:30, Peter Otten wrote: > wrote: > > > I have several millions of documents in several folders and subfolders in > > my machine. I tried to write a script as follows, to extract all the .doc > > files and to convert them in text, but it seems it is taki

Problem in Handling MySql Data.

2015-05-02 Thread subhabrata . banerji
Dear Group, I am trying to write the following script to call around 0.3 million files from a remote server. It is generally working fine, but could work only upto 65 to 70 files. After this, it is just printing the file names and not processing anything. If anyone may kindly suggest what I am

Re: Problem in Handling MySql Data.

2015-05-02 Thread Chris Angelico
On Sat, May 2, 2015 at 8:42 PM, wrote: > Dear Group, > > I am trying to write the following script to call around 0.3 million files > from a remote server. > It is generally working fine, but could work only upto 65 to 70 files. After > this, it is just > printing the file names and not process

Re: Python is not bad ;-)

2015-05-02 Thread Christian Gollwitzer
Am 02.05.15 um 11:58 schrieb Marko Rauhamaa: Chris Angelico : Guido is against anything that disrupts tracebacks, and optimizing tail recursion while maintaining traceback integrity is rather harder. Tail recursion could be suppressed during debugging. Optimized code can play all kinds of non

Re: Python is not bad ;-)

2015-05-02 Thread Cecil Westerhof
Op Saturday 2 May 2015 11:10 CEST schreef Marko Rauhamaa: > Cecil Westerhof : >> I find factorial a lot cleaner code as factorial_iterative, so here >> tail recursion would be beneficial. > > I would just call math.factorial() and be done with it. You missed the point. I did not need a factorial

Re: Python is not bad ;-)

2015-05-02 Thread Chris Angelico
On Sat, May 2, 2015 at 9:07 PM, Christian Gollwitzer wrote: > I need to add, I grew up with imperative programming, and as such got > recursion as the solution to problems that are too complex for iteration, > i.e. tree traversal and such, and exactly these are never tail-recursive. Tree traversa

Re: Python is not bad ;-)

2015-05-02 Thread Cecil Westerhof
Op Saturday 2 May 2015 12:35 CEST schreef Dave Angel: > On 05/02/2015 05:33 AM, Cecil Westerhof wrote: > > Please check your email settings. Your messages that you type seem > to be indented properly, but those that are quoting earlier messages > (even your own) are not. See below. I suspect there

Re: Python is not bad ;-)

2015-05-02 Thread Christian Gollwitzer
Am 02.05.15 um 13:21 schrieb Chris Angelico: On Sat, May 2, 2015 at 9:07 PM, Christian Gollwitzer wrote: I need to add, I grew up with imperative programming, and as such got recursion as the solution to problems that are too complex for iteration, i.e. tree traversal and such, and exactly thes

Re: Python is not bad ;-)

2015-05-02 Thread Marko Rauhamaa
Christian Gollwitzer : > That's why I still think it is a microoptimization, which helps only > in some specific cases. It isn't done for performance. It's done to avoid a stack overflow exception. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: convert pdf to excel xls file

2015-05-02 Thread David H. Lipman
From: This is a very common problem That problem is called spam coupled with Google who facilitating it. -- Dave Multi-AV Scanning Tool - http://multi-av.thespykiller.co.uk http://www.pctipp.ch/downloads/dl/35905.asp -- https://mail.python.org/mailman/listinfo/python-list

Re: convert pdf to excel xls file

2015-05-02 Thread Grant Edwards
On 2015-05-02, David H. Lipman wrote: > From: > >> >> This is a very common problem > > That problem is called spam coupled with Google who facilitating it. The problem is called "seeing responses to spam that had bee properly filtered out". -- Grant -- https://mail.python.org/mailman/lis

Throw the cat among the pigeons

2015-05-02 Thread Cecil Westerhof
I am throwing the cat among the pigeons. ;-) In another thread I mentioned that I liked to have tail recursion in Python. To be clear not automatic, but asked for. Looking at the replies I did hit a nerve. But I still want to continue. Some things are better expressed recursively for the people

Re: l = range(int(1E9))

2015-05-02 Thread BartC
On 30/04/2015 18:20, Ben Finney wrote: Jon Ribbens writes: If you use xrange() instead of range() then you will get an iterator which will return each of the numbers in turn without any need to create an enormous list of all of them. If you use Python 3 instead of the obsolescent Python 2,

Re: Python is not bad ;-)

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 4:35 AM, Dave Angel wrote: > I can't see how that is worth doing. The recursive version is already a > distortion of the definition of factorial that I learned. And to force it > to be recursive and also contort it so it does the operations in the same > order as the iterat

Re: Custom alphabetical sort

2015-05-02 Thread Pander Musubi
On Monday, 24 December 2012 16:32:56 UTC+1, Pander Musubi wrote: > Hi all, > > I would like to sort according to this order: > > (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', > 'A', 'ä', 'Ä', 'á', 'Á', 'â', 'Â', 'à', 'À', 'å', 'Å', 'b', 'B', 'c', 'C', > 'ç', 'Ç',

Re: l = range(int(1E9))

2015-05-02 Thread Mark Lawrence
On 02/05/2015 16:26, BartC wrote: On 30/04/2015 18:20, Ben Finney wrote: Jon Ribbens writes: If you use xrange() instead of range() then you will get an iterator which will return each of the numbers in turn without any need to create an enormous list of all of them. If you use Python 3 in

Re: Python is not bad ;-)

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 5:42 AM, Marko Rauhamaa wrote: > Christian Gollwitzer : > >> That's why I still think it is a microoptimization, which helps only >> in some specific cases. > > It isn't done for performance. It's done to avoid a stack overflow > exception. If your tree is balanced, then th

Re: Python is not bad ;-)

2015-05-02 Thread Chris Angelico
On Sun, May 3, 2015 at 1:45 AM, Ian Kelly wrote: > On Sat, May 2, 2015 at 5:42 AM, Marko Rauhamaa wrote: >> Christian Gollwitzer : >> >>> That's why I still think it is a microoptimization, which helps only >>> in some specific cases. >> >> It isn't done for performance. It's done to avoid a stac

Re: l = range(int(1E9))

2015-05-02 Thread BartC
On 02/05/2015 16:40, Mark Lawrence wrote: On 02/05/2015 16:26, BartC wrote: On 30/04/2015 18:20, Ben Finney wrote: Jon Ribbens writes: If you use xrange() instead of range() then you will get an iterator which will return each of the numbers in turn without any need to create an enormous li

Re: l = range(int(1E9))

2015-05-02 Thread Mark Lawrence
On 02/05/2015 17:17, BartC wrote: On 02/05/2015 16:40, Mark Lawrence wrote: On 02/05/2015 16:26, BartC wrote: On 30/04/2015 18:20, Ben Finney wrote: Jon Ribbens writes: If you use xrange() instead of range() then you will get an iterator which will return each of the numbers in turn withou

Re: Python is not bad ;-)

2015-05-02 Thread Joonas Liik
I agree, stack overflow is literally the main issue that ive run in to (tree traversal) I've yet to refactor recursion to iterative for speed, but i have done so to avoid hitting the stack size limit. Tree traversal and similar problems in particular lend themselves well to recursion and are not q

Re: Python is not bad ;-)

2015-05-02 Thread Joonas Liik
Balancing of trees is kind of irrelevant when "tree" means "search space" no? And you definitely dont need to keep the entire tree in memory at the same time. By cropping unsuitable branches early (and not keeping the entire tree in memory) it is quite easy to have more than 1000 of call stack and

Try Except Specific Error Messages

2015-05-02 Thread brandon wallace
Hi,   I am try to get more specific error messages using try/except. I ran this code with the cable unplugged to see the error message. I got #!/usr/bin/env python3 import urllib.request webpage = urllib.request.urlopen("http://fakewebsite.com/";) text = webpage.read().decode("utf8") I got t

Re: Python is not bad ;-)

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 9:55 AM, Chris Angelico wrote: > On Sun, May 3, 2015 at 1:45 AM, Ian Kelly wrote: >> On Sat, May 2, 2015 at 5:42 AM, Marko Rauhamaa wrote: >>> Christian Gollwitzer : >>> That's why I still think it is a microoptimization, which helps only in some specific cases.

Re: Python is not bad ;-)

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 9:53 AM, Joonas Liik wrote: Top-posting is heavily frowned at on this list, so please don't do it. > Balancing of trees is kind of irrelevant when "tree" means "search space" > no? I think it's relatively rare that DFS is truly the best algorithm for such a search. For on

Re: Python is not bad ;-)

2015-05-02 Thread Mark Lawrence
On 02/05/2015 14:50, Joonas Liik wrote: [top posting fixed] On 2 May 2015 at 14:42, Marko Rauhamaa wrote: Christian Gollwitzer : That's why I still think it is a microoptimization, which helps only in some specific cases. It isn't done for performance. It's done to avoid a stack overflo

Re: Try Except Specific Error Messages

2015-05-02 Thread Gary Herron
On 04/30/2015 04:27 PM, brandon wallace wrote: Hi, I am try to get more specific error messages using try/except. I ran this code with the cable unplugged to see the error message. I got #!/usr/bin/env python3 import urllib.request webpage = urllib.request.urlopen("http://fakewebsite.com/"

Re: l = range(int(1E9))

2015-05-02 Thread BartC
On 02/05/2015 17:39, Mark Lawrence wrote: On 02/05/2015 17:17, BartC wrote: On 02/05/2015 16:40, Mark Lawrence wrote: for item in items: When did this change, or has it always been this way and you were simply using an idiom from other languages? Your example is the equivalent of 'forall'

Re: l = range(int(1E9))

2015-05-02 Thread Mark Lawrence
On 02/05/2015 19:34, BartC wrote: On 02/05/2015 17:39, Mark Lawrence wrote: On 02/05/2015 17:17, BartC wrote: On 02/05/2015 16:40, Mark Lawrence wrote: for item in items: When did this change, or has it always been this way and you were simply using an idiom from other languages? Your ex

Re: l = range(int(1E9))

2015-05-02 Thread Marko Rauhamaa
BartC : > (I tried an empty loop counting to 1 billion in Python 2.x, using 'for > i in range'. It ran out of memory. Counting to 100 million instead, it > worked, but still used a massive 1.5GB RAM while doing so (and took 6 > seconds to count to 100M, not too bad for Python) > > Outside Python,

Re: Custom alphabetical sort

2015-05-02 Thread Dave Angel
On 05/02/2015 11:35 AM, Pander Musubi wrote: On Monday, 24 December 2012 16:32:56 UTC+1, Pander Musubi wrote: Hi all, I would like to sort according to this order: (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'A', 'ä', 'Ä', 'á', 'Á', 'â', 'Â', 'à', 'À', 'å', '

Re: Custom alphabetical sort

2015-05-02 Thread Joel Goldstick
On Sat, May 2, 2015 at 3:25 PM, Dave Angel wrote: > On 05/02/2015 11:35 AM, Pander Musubi wrote: >> >> On Monday, 24 December 2012 16:32:56 UTC+1, Pander Musubi wrote: >>> >>> Hi all, >>> >>> I would like to sort according to this order: >>> >>> (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5',

Re: l = range(int(1E9))

2015-05-02 Thread Marko Rauhamaa
Mark Lawrence : > On 02/05/2015 19:34, BartC wrote: >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] >> [...] [etc etc etc] > > I give up. Mark, you do a commendable job admonishing the forum participants against top-posting. Let

Canopy editor

2015-05-02 Thread lbertolotti via Python-list
I having some problems with Python editor Canopy: -- https://mail.python.org/mailman/listinfo/python-list

Canopy editor-Variables browser and help

2015-05-02 Thread lbertolotti via Python-list
Can I: 1.Enable a variable browser in Canopy editor similar to the Spyder editor? 2.Writing a function say log( gives me the function help, but I can't read the whole documentation 3.Eclipse had a auto-complete, can I enable this in Canopy? 4.Perhaps I should try using another editor? I was having

Re: l = range(int(1E9))

2015-05-02 Thread BartC
On 02/05/2015 20:15, Mark Lawrence wrote: On 02/05/2015 19:34, BartC wrote: OK, so it's the programmer's fault if as fundamental a concept as a for-loop ranging over integers is implemented inefficiently. He has to transform it into high-level terms, or has to reconstruct it somehow using a wh

Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-02 Thread vasudevram
Hi group, Please refer to this blog post about code showing that a Python data structure can be self-referential: http://jugad2.blogspot.in/2015/05/can-python-data-structure-reference.html Gotten a couple of comments on it already, but interested in hearing thoughts of Python core dev team mem

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-02 Thread Tim Chase
[dangit, had Control down when I hit and it sent prematurely] On 2015-05-02 13:02, vasudevram wrote: > http://jugad2.blogspot.in/2015/05/can-python-data-structure-reference.html > > https://docs.python.org/2/reference/datamodel.html > > and saw this excerpt: > > [ CPython implementation detail:

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-02 Thread Tim Chase
On 2015-05-02 13:02, vasudevram wrote: > Hi group, > > Please refer to this blog post about code showing that a Python > data structure can be self-referential: > > http://jugad2.blogspot.in/2015/05/can-python-data-structure-reference.html > > Gotten a couple of comments on it already, but inter

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-02 Thread vasudevram
On Sunday, May 3, 2015 at 1:47:04 AM UTC+5:30, Tim Chase wrote: > [dangit, had Control down when I hit and it sent prematurely] > > On 2015-05-02 13:02, vasudevram wrote: > > http://jugad2.blogspot.in/2015/05/can-python-data-structure-reference.html > > > > https://docs.python.org/2/reference/dat

Re: l = range(int(1E9))

2015-05-02 Thread Joel Goldstick
>> I give up. > > > So do I, I think, if no-one is willing to admit that the original way of > implementing range() was a glaring mistake. > > > -- > Bartc > It doesn't matter for small ranges. Anyway it was fixed. > > > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldsti

Re: Is my implementation of happy number OK

2015-05-02 Thread Jon Ribbens
On 2015-05-01, Peter Otten <__pete...@web.de> wrote: > A computer that cannot calculate a lookup table with all 3-digit cases > should be almost as hard to find as the one needed by Jon ;) ... or anyone else writing code to return the set of happy numbers. -- https://mail.python.org/mailman/list

Re: l = range(int(1E9))

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 1:51 PM, BartC wrote: > On 02/05/2015 20:15, Mark Lawrence wrote: >> >> On 02/05/2015 19:34, BartC wrote: > > >>> OK, so it's the programmer's fault if as fundamental a concept as a >>> for-loop ranging over integers is implemented inefficiently. He has to >>> transform it i

Re: l = range(int(1E9))

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 3:28 PM, Tony the Tiger wrote: > On Fri, 01 May 2015 14:42:04 +1000, Steven D'Aprano wrote: > >> use "l" as a variable name, as it looks too much like 1 > > If you use a better font, they are very different. Besides, a variable > name cannot start with a digit (nor can it be

Re: l = range(int(1E9))

2015-05-02 Thread Jon Ribbens
On 2015-05-02, BartC wrote: > So do I, I think, if no-one is willing to admit that the original way of > implementing range() was a glaring mistake. I think the issue is that nobody else here thinks the "original way" of iterating was to use range(), for anything other than extremely small range

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-02 Thread Cecil Westerhof
Op Saturday 2 May 2015 22:17 CEST schreef Tim Chase: > [dangit, had Control down when I hit and it sent > prematurely] > > On 2015-05-02 13:02, vasudevram wrote: >> http://jugad2.blogspot.in/2015/05/can-python-data-structure-reference.html >> >> https://docs.python.org/2/reference/datamodel.html

Python xlrd

2015-05-02 Thread lbertolotti via Python-list
Ubuntu terminal gives me: import xlrd I get "ImportError: No module named xlrd" Any ideas? I installed it by: sudo apt-get install python-xlrd -- https://mail.python.org/mailman/listinfo/python-list

Re: l = range(int(1E9))

2015-05-02 Thread Mark Lawrence
On 02/05/2015 22:40, Jon Ribbens wrote: On 2015-05-02, BartC wrote: So do I, I think, if no-one is willing to admit that the original way of implementing range() was a glaring mistake. I think the issue is that nobody else here thinks the "original way" of iterating was to use range(), for an

Re: l = range(int(1E9))

2015-05-02 Thread BartC
On 02/05/2015 22:40, Jon Ribbens wrote: On 2015-05-02, BartC wrote: So do I, I think, if no-one is willing to admit that the original way of implementing range() was a glaring mistake. I think the issue is that nobody else here thinks the "original way" of iterating was to use range(), for an

Re: l = range(int(1E9))

2015-05-02 Thread Terry Reedy
On 5/2/2015 11:26 AM, BartC wrote: When I first looked at Python 20 or so years ago this seemed to be the standard way of writing a for-loop: for i in range(N): As Mark said, the actual syntax was originally for item in sequence: ... where sequence technically meant an object with

Is this a good way to implement testing

2015-05-02 Thread Cecil Westerhof
Still on my journey to learn Python. At the moment I define the test functionality in the following way: if __name__ == '__main__': keywords= [ 'all', 'factorial', 'fibonacci', 'happy', 'lucky', ] keywo

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-02 Thread MRAB
On 2015-05-02 22:06, Cecil Westerhof wrote: Op Saturday 2 May 2015 22:17 CEST schreef Tim Chase: [dangit, had Control down when I hit and it sent prematurely] On 2015-05-02 13:02, vasudevram wrote: http://jugad2.blogspot.in/2015/05/can-python-data-structure-reference.html https://docs.pytho

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-02 Thread Terry Reedy
On 5/2/2015 4:02 PM, vasudevram wrote: Hi group, Please refer to this blog post about code showing that a Python data structure can be self-referential: http://jugad2.blogspot.in/2015/05/can-python-data-structure-reference.html Gotten a couple of comments on it already, but interested in hear

Re: Is this a good way to implement testing

2015-05-02 Thread Mark Lawrence
On 02/05/2015 23:29, Cecil Westerhof wrote: Still on my journey to learn Python. At the moment I define the test functionality in the following way: if __name__ == '__main__': keywords= [ 'all', 'factorial', 'fibonacci', '

Re: l = range(int(1E9))

2015-05-02 Thread Terry Reedy
On 5/2/2015 5:40 PM, Jon Ribbens wrote: For information, it looks like xrange() was added on 26 Oct 1993, which pre-dates Python 1.0. 1.0 was released Feb 1991. 3.2 exactly 20 years later. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: l = range(int(1E9))

2015-05-02 Thread Terry Reedy
On 5/2/2015 5:31 PM, Ian Kelly wrote: Would it have been better if range() had been implemented as xrange() from the beginning? Sure, that would have been great. Except for one small detail: the iterator protocol didn't exist back then. For loops originally used the getitem iterator protocol.

Re: l = range(int(1E9))

2015-05-02 Thread Jon Ribbens
On 2015-05-02, Terry Reedy wrote: > On 5/2/2015 5:40 PM, Jon Ribbens wrote: >> For information, it looks like xrange() was added on 26 Oct 1993, >> which pre-dates Python 1.0. > > 1.0 was released Feb 1991. 3.2 exactly 20 years later. No, you are thinking of 0.9, which was indeed February 1991.

Re: Is this a good way to implement testing

2015-05-02 Thread Terry Reedy
On 5/2/2015 6:29 PM, Cecil Westerhof wrote: At the moment I define the test functionality in the following way: Any automated testing is better than none. For idlelib, I use unittest. For an individual project with specialized needs, I use a custom test framework tuned to those needs.

Re: l = range(int(1E9))

2015-05-02 Thread Jon Ribbens
On 2015-05-02, BartC wrote: > On 02/05/2015 22:40, Jon Ribbens wrote: >> I think the issue is that nobody else here thinks the "original way" >> of iterating was to use range(), for anything other than extremely >> small ranges. > > What /is/ the way to iterate then? Other people have already exp

Re: l = range(int(1E9))

2015-05-02 Thread Michael Torrie
On 05/02/2015 04:33 PM, BartC wrote: > OK, so it's just an irritation then, as a workaround has been available > for a long time. (For example, if you use xrange, it won't work on 3.x. > If you use range, then it might be inefficient on 2.x.) In both Python 2.7 and 3.3+, you can use the 3rd-part

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-02 Thread Tim Chase
On 2015-05-02 23:06, Cecil Westerhof wrote: > Op Saturday 2 May 2015 22:17 CEST schreef Tim Chase: >> This creates a cycle, then makes it unreachable, but the list is >> still referenced by itself, so the reference count never drops to >> zero (where it would get GC'd), and thus that item lingers a

Re: l = range(int(1E9))

2015-05-02 Thread Mark Lawrence
On 03/05/2015 03:07, Michael Torrie wrote: On 05/02/2015 04:33 PM, BartC wrote: OK, so it's just an irritation then, as a workaround has been available for a long time. (For example, if you use xrange, it won't work on 3.x. If you use range, then it might be inefficient on 2.x.) In both Python

Re: l = range(int(1E9))

2015-05-02 Thread Terry Reedy
On 5/2/2015 8:01 PM, Jon Ribbens wrote: On 2015-05-02, Terry Reedy wrote: On 5/2/2015 5:40 PM, Jon Ribbens wrote: For information, it looks like xrange() was added on 26 Oct 1993, which pre-dates Python 1.0. 1.0 was released Feb 1991. 3.2 exactly 20 years later. No, you are thinking of 0.

Re: l = range(int(1E9))

2015-05-02 Thread Jon Ribbens
On 2015-05-03, Terry Reedy wrote: > On 5/2/2015 8:01 PM, Jon Ribbens wrote: >> On 2015-05-02, Terry Reedy wrote: >>> On 5/2/2015 5:40 PM, Jon Ribbens wrote: For information, it looks like xrange() was added on 26 Oct 1993, which pre-dates Python 1.0. >>> >>> 1.0 was released Feb 1991.

Re: Is this a good way to implement testing

2015-05-02 Thread Paul Rubin
Cecil Westerhof writes: > Still on my journey to learn Python. > > At the moment I define the test functionality in the following way: > action = options[0][0] > if action == '--all': ... Yecch, use an option parsing library for that, whichever one is currently fashiona

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 7:57 PM, Tim Chase wrote: > So it sounds like you have to request such a mark-and-sweep from > the gc module. You *can* request it. But as long as it hasn't been explicitly disabled (by calling gc.disable()), the mark-and-sweep garbage collection will also run automatically

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 2:17 PM, Tim Chase wrote: > If you know that you're creating such cyclical structures, it's best > to manually unlink them before freeing them: > > lst = [] > lst.append(lst) # create the cycle > lst[:] = [] # break the cycle > # or lst.remove(lst) # though this ta

Re: Is this a good way to implement testing

2015-05-02 Thread Ben Finney
Paul Rubin writes: > Cecil Westerhof writes: > > > action = options[0][0] > > if action == '--all': ... > > Yecch, use an option parsing library for that, whichever one is > currently fashionable. I think optparse is deprecated now but I still > use it because I'm used

Re: l = range(int(1E9))

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 5:51 PM, Terry Reedy wrote: > On 5/2/2015 5:31 PM, Ian Kelly wrote: > >> Would it have been better if range() had been implemented as xrange() >> from the beginning? Sure, that would have been great. Except for one >> small detail: the iterator protocol didn't exist back the

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-02 Thread Chris Angelico
On Sun, May 3, 2015 at 2:43 PM, Ian Kelly wrote: > On Sat, May 2, 2015 at 2:17 PM, Tim Chase > wrote: >> If you know that you're creating such cyclical structures, it's best >> to manually unlink them before freeing them: >> >> lst = [] >> lst.append(lst) # create the cycle >> lst[:] = []

code blocks

2015-05-02 Thread Dr. John Q. Hacker
Hello, I'm thinking how interesting it would be to add code blocks to Python, so that arbitrary strings of code can be passed around. It would open up some interesting possibilities for self-modifying code and generic programming. Since Python has already a plethora of ambiguous string designat

Re: Python xlrd

2015-05-02 Thread Ervin Hegedüs
hi, On Sat, May 02, 2015 at 03:12:46PM -0700, lbertolotti via Python-list wrote: > Ubuntu terminal gives me: > > import xlrd > > I get "ImportError: No module named xlrd" > > Any ideas? I installed it by: > > sudo apt-get install python-xlrd what's the answers of your system for these questio