Re: Let exception fire or return None

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 10:18 CEST schreef Dave Angel: On 04/30/2015 03:43 AM, Cecil Westerhof wrote: I have a function to fetch a message from a file: def get_indexed_message(message_filename, index): Get index message from a file, where 0 gets the first message return

Re: Let exception fire or return None

2015-04-30 Thread Peter Otten
Cecil Westerhof wrote: I have a function to fetch a message from a file: def get_indexed_message(message_filename, index): Get index message from a file, where 0 gets the first message return open(expanduser(message_filename),

Re: Lucky numbers in Python

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 04:55 CEST schreef Ian Kelly: On Wed, Apr 29, 2015 at 6:01 PM, Cecil Westerhof ce...@decebal.nl wrote: Op Thursday 30 Apr 2015 00:38 CEST schreef Ian Kelly: In that case you can definitely omit the middle term of the slice, which will be both more concise and clearer

Re: seek operation in python

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 09:33 CEST schreef Chris Angelico: On Thu, Apr 30, 2015 at 4:27 PM, Cecil Westerhof ce...@decebal.nl wrote: with open(input.cpp) as f: lines = f.readlines() print(lines[7]) Is the following not better: print(open('input.cpp', 'r').readlines()[7]) Time is the same

Re: Let exception fire or return None

2015-04-30 Thread Dave Angel
On 04/30/2015 03:43 AM, Cecil Westerhof wrote: I have a function to fetch a message from a file: def get_indexed_message(message_filename, index): Get index message from a file, where 0 gets the first message return open(expanduser(message_filename),

Re: seek operation in python

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 02:33 CEST schreef Chris Angelico: On Thu, Apr 30, 2015 at 4:08 AM, siva sankari R buddingros...@gmail.com wrote: file=open(input,r) line=file.seek(7) print line The above code is supposed to print a line but it prints none. I don't know where the mistake is.

Re: seek operation in python

2015-04-30 Thread Dave Angel
On 04/30/2015 04:06 AM, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 09:33 CEST schreef Chris Angelico: On Thu, Apr 30, 2015 at 4:27 PM, Cecil Westerhof ce...@decebal.nl wrote: with open(input.cpp) as f: lines = f.readlines() print(lines[7]) Is the following not better:

[issue24079] xml.etree.ElementTree.Element.text does not conform to the documentation

2015-04-30 Thread Raymond Hettinger
Raymond Hettinger added the comment: this is well formed xml and has nothing to do with tail. In fact, it does have something to do with tail. The 'TEXT' is a captured as the tail of element b: root3 = ET.fromstring('ab/TEXT/a') root3[0].tail 'TEXT' -- nosy: +eli.bendersky,

Python is not bad ;-)

2015-04-30 Thread Cecil Westerhof
I am coding with Python again. I like it that the code is concise and clear. But also that the performance is not bad. I wrote Lucky Numbers in Clojure and Python. When calling with 1E7 Clojure takes 12 seconds and Python 8 seconds. When calling it with 1E8 Clojure takes all 4/8 cores and gets an

[issue24005] Documentation Error: Extra line Break

2015-04-30 Thread Tim Golden
Tim Golden added the comment: Jaivish Kothari, Thanks for making the effort to contribute. Can I suggest you have a look at the Core Mentorship site: http://pythonmentors.com/ and perhaps join the Core Mentorship list: http://mail.python.org/mailman/listinfo/core-mentorship TJG

Re: seek operation in python

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 10:31 CEST schreef Dave Angel: On 04/30/2015 04:06 AM, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 09:33 CEST schreef Chris Angelico: On Thu, Apr 30, 2015 at 4:27 PM, Cecil Westerhof ce...@decebal.nl wrote: with open(input.cpp) as f: lines = f.readlines()

Re: seek operation in python

2015-04-30 Thread Chris Angelico
On Thu, Apr 30, 2015 at 4:27 PM, Cecil Westerhof ce...@decebal.nl wrote: with open(input.cpp) as f: lines = f.readlines() print(lines[7]) Is the following not better: print(open('input.cpp', 'r').readlines()[7]) Time is the same (about 25 seconds for 100.000 calls), but I find this

[issue24079] xml.etree.ElementTree.Element.text does not conform to the documentation

2015-04-30 Thread Stefan Behnel
Stefan Behnel added the comment: I agree that the wording in the documentation isn't great: text The text attribute can be used to hold additional data associated with the element. As the name implies this attribute is usually a string but may be any application-specific object. If the

Let exception fire or return None

2015-04-30 Thread Cecil Westerhof
I have a function to fetch a message from a file: def get_indexed_message(message_filename, index): Get index message from a file, where 0 gets the first message return open(expanduser(message_filename), 'r').readlines()[index].rstrip() What is more the

Re: Python is not bad ;-)

2015-04-30 Thread Ben Finney
Cecil Westerhof ce...@decebal.nl writes: I am coding with Python again. Great to know! I like it that the code is concise and clear. But also that the performance is not bad. The former is a property of Python, which is a programming language. I agree with your assessment :-) The latter is

Re: seek operation in python

2015-04-30 Thread Chris Angelico
On Thu, Apr 30, 2015 at 7:06 PM, Cecil Westerhof ce...@decebal.nl wrote: I already done it. I thought it not to much work. And it even makes some code shorter: -marshal_file= open(expanduser(marshal_filename), 'r') -not_list= load(marshal_file) -marshal_file.close() -

Re: Python is not bad ;-)

2015-04-30 Thread Chris Angelico
On Thu, Apr 30, 2015 at 8:16 PM, Marko Rauhamaa ma...@pacujo.net wrote: Ben Finney ben+pyt...@benfinney.id.au: The latter is not a property of Python; a programming language doesn't have runtime performance. Rather, runtime performance is a property of some specific *implementation* — that

[issue21423] concurrent.futures.ThreadPoolExecutor/ProcessPoolExecutor should accept an initializer argument

2015-04-30 Thread Claudiu Popa
Changes by Claudiu Popa pcmantic...@gmail.com: -- stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21423 ___ ___

[issue21423] concurrent.futures.ThreadPoolExecutor/ProcessPoolExecutor should accept an initializer argument

2015-04-30 Thread Claudiu Popa
Changes by Claudiu Popa pcmantic...@gmail.com: -- nosy: +Claudiu.Popa ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21423 ___ ___ Python-bugs-list

[issue21518] Expose RegUnLoadKey in winreg

2015-04-30 Thread Claudiu Popa
Claudiu Popa added the comment: Hello, Can anyone review the last patch? Hopefully it is the final version, since the beta is really at the corner and I definitely would like to have this in 3.5. -- ___ Python tracker rep...@bugs.python.org

Re: Python is not bad ;-)

2015-04-30 Thread Marko Rauhamaa
Ben Finney ben+pyt...@benfinney.id.au: The latter is not a property of Python; a programming language doesn't have runtime performance. Rather, runtime performance is a property of some specific *implementation* — that is, the runtime Python machine. There are numerous Python runtimes, and

[issue4356] Add key argument to bisect module functions

2015-04-30 Thread Eric Reynolds
Eric Reynolds added the comment: In the meantime here is a workaround https://gist.github.com/ericremoreynolds/2d80300dabc70eebc790 -- nosy: +ericreynolds ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4356

Re: Python is not bad ;-)

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 12:16 CEST schreef Marko Rauhamaa: Ben Finney ben+pyt...@benfinney.id.au: The latter is not a property of Python; a programming language doesn't have runtime performance. Rather, runtime performance is a property of some specific *implementation* — that is, the

Re: Let exception fire or return None

2015-04-30 Thread Peter Otten
Cecil Westerhof wrote: (2) you may want to take measures to limit memory usage, e. g. assert index = 0 I put that in, but as first statement. For the record, this was not a recommended check, but rather a way to communicate to the reader of my code that unlike yours it doesn't support

[issue24079] xml.etree.ElementTree.Element.text does not conform to the documentation

2015-04-30 Thread Jérôme Laurens
Jérôme Laurens added the comment: Since the text and tail notions seem tightly coupled, I would vote for a more detailed explanation in the text doc and a forward link in the tail documentation. text The text attribute holds the text between the element's begin tag and the next tag or

Re: seek operation in python

2015-04-30 Thread Cecil Westerhof
Op Wednesday 29 Apr 2015 20:08 CEST schreef siva sankari R.: file=open(input,r) line=file.seek(7) print line The above code is supposed to print a line but it prints none. I don't know where the mistake is. Help.! You could use my module:

Re: Let me introduce myself.

2015-04-30 Thread Tim Golden
On 30/04/2015 12:48, Luca Menegotto wrote: Hello everybody. Hi Luca, One of the common rules i like most is: when you enter in a community, introduce yourself! In fact, many people don't on this list, so it's nice of you to offer us this courtesy :) So here I am! Luca, old developer

Re: Let exception fire or return None

2015-04-30 Thread Thomas 'PointedEars' Lahn
Cecil Westerhof wrote: I have a function to fetch a message from a file: def get_indexed_message(message_filename, index): Get index message from a file, where 0 gets the first message return open(expanduser(message_filename),

Re: Let exception fire or return None

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 13:26 CEST schreef Cecil Westerhof: try: [line] = itertools.islice(f, index, index+1) except ValueError: raise IndexError return line.rstrip() In my case it is not important. (The biggest file I use has between 100 and 200 lines), but I publish it, so I should do

Re: Python is not bad ;-)

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 11:10 CEST schreef Ben Finney: I like it that the code is concise and clear. But also that the performance is not bad. The former is a property of Python, which is a programming language. I agree with your assessment :-) The latter is not a property of Python; a

Re: Let exception fire or return None

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 11:30 CEST schreef Peter Otten: Cecil Westerhof wrote: I have a function to fetch a message from a file: def get_indexed_message(message_filename, index): Get index message from a file, where 0 gets the first message return open(expanduser(message_filename),

Let me introduce myself.

2015-04-30 Thread Luca Menegotto
Hello everybody. One of the common rules i like most is: when you enter in a community, introduce yourself! So here I am! Luca, old developer (50 and still running!), Python (and not only) developer, from Marostica, a lovely small town in the north-eastern part of Italy. It's a pleasure

Re: Let exception fire or return None

2015-04-30 Thread Antoon Pardon
Op 30-04-15 om 09:43 schreef Cecil Westerhof: I have a function to fetch a message from a file: def get_indexed_message(message_filename, index): Get index message from a file, where 0 gets the first message return open(expanduser(message_filename),

Re: Let exception fire or return None

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 14:28 CEST schreef Peter Otten: Cecil Westerhof wrote: (2) you may want to take measures to limit memory usage, e. g. assert index = 0 I put that in, but as first statement. For the record, this was not a recommended check, but rather a way to communicate to the

[issue23910] property_descr_get reuse argument tuple

2015-04-30 Thread Roundup Robot
Roundup Robot added the comment: New changeset 661cdbd617b8 by Raymond Hettinger in branch 'default': Issue #23910: Optimize property() getter calls. Patch by Joe Jevnik https://hg.python.org/cpython/rev/661cdbd617b8 -- nosy: +python-dev ___ Python

[issue24082] Obsolete note in argument parsing (c-api/arg.rst)

2015-04-30 Thread Petr Viktorin
New submission from Petr Viktorin: A note in the docs for the u format unit saus NULs are not allowed, but the previous sentence says they aren't accepted. -- assignee: docs@python components: Documentation files: 0002-Remove-obsolete-note-in-argument-parsing-docs.patch keywords: patch

[issue10544] yield expression inside generator expression does nothing

2015-04-30 Thread A. Jesse Jiryu Davis
Changes by A. Jesse Jiryu Davis je...@emptysquare.net: -- nosy: +emptysquare ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10544 ___ ___

[issue24080] asyncio.Event.wait() Task was destroyed but it is pending

2015-04-30 Thread Matt Johnston
New submission from Matt Johnston: asyncio.Event.wait() doesn't seem to be cancelled by asyncio.wait_for(). Ctrl-c in the attached example produces output below. I'm not certain the code is correct though the documentation for wait_for() suggests it should work. Without the wait_for() it

[issue24081] Obsolete caveat in reload() docs

2015-04-30 Thread Petr Viktorin
New submission from Petr Viktorin: imp.reload() and importlib.reload() docs state:: If a module is syntactically correct but its initialization fails, the first :keyword:`import` statement for it does not bind its name locally, but does store a (partially initialized) module object

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

2015-04-30 Thread Ben Finney
Jon Ribbens jon+use...@unequivocal.co.uk writes: On 2015-04-30, Cecil Westerhof ce...@decebal.nl wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. […] Is there a way to circumvent Python claiming all the memory? You seem to be

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

2015-04-30 Thread Grant Edwards
On 2015-04-30, Cecil Westerhof ce...@decebal.nl wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to it. This make those programs more slowly.

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

2015-04-30 Thread Terry Reedy
On 4/30/2015 12:06 PM, Cecil Westerhof wrote: If I execute: l = range(int(1E9) you get a SyntaxError The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to it. This make those

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

2015-04-30 Thread Gisle Vanem
Cecil Westerhof wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to it. This make those programs more slowly. Is there a way to circumvent

l = range(int(1E9))

2015-04-30 Thread Cecil Westerhof
If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to it. This make those programs more slowly. Is there a way to circumvent Python claiming all the

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

2015-04-30 Thread Gary Herron
On 04/30/2015 09:06 AM, Cecil Westerhof wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to it. This make those programs more slowly. Is there

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

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 18:33 CEST schreef Grant Edwards: On 2015-04-30, Cecil Westerhof ce...@decebal.nl wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes

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

2015-04-30 Thread Ben Finney
Cecil Westerhof ce...@decebal.nl writes: That works, yes. Now I get a MemoryError and the other processes are left alone. Now determining what are the best values. I would strongly recommend that “best values” includes “run Python version = 3”. One of the many problems you avoid by leaving

Re: mixing set and list operations

2015-04-30 Thread Tim
On Thursday, April 30, 2015 at 1:05:05 PM UTC-4, Ben Finney wrote: Tim writes: You can use 'extend' to add set elements to a list and use 'update' to add list elements to a set. And you can use both of those methods to add items from a file:: foo = ['one', 'two'] bar =

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

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 18:55 CEST schreef Jon Ribbens: On 2015-04-30, Cecil Westerhof ce...@decebal.nl wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes

[issue24079] xml.etree.ElementTree.Element.text does not conform to the documentation

2015-04-30 Thread Jérôme Laurens
Jérôme Laurens added the comment: Erratum def innertext(elt): return (elt.text or '') +''.join(innertext(e)+(e.tail or '') for e in elt) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24079

Re: Is my implementation of happy number OK

2015-04-30 Thread Jon Ribbens
On 2015-04-30, Cecil Westerhof ce...@decebal.nl wrote: Besides it need some documentation: is it a good implementation? Or are there things I should do differently? Here's an alternative implementation which is a bit neater: def find_happy(maximum): Return set of happy numbers

Re: Is my implementation of happy number OK

2015-04-30 Thread Ian Kelly
On Thu, Apr 30, 2015 at 9:59 AM, Cecil Westerhof ce...@decebal.nl wrote: I implemented happy_number function: _happy_set = { '1' } _unhappy_set= set() def happy_number(n): Check if a number is a happy number

[issue24060] Clearify necessities for logging with timestamps

2015-04-30 Thread R. David Murray
R. David Murray added the comment: Not to my eyes. It clearly says that if no formatting string is specified, the default is used, and that formatTime is used only if the message string contains asctime. Up to Vinay whether he thinks it is worth adding something like which does not include

Re: Python is not bad ;-)

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 16:03 CEST schreef Michael Torrie: On 04/30/2015 01:07 AM, Cecil Westerhof wrote: When I do that the computer is freezed a few times. That is a little less nice. Does not happen with Clojure when it gets an out of memory. A system freeze is probably due to thrashing

[issue24079] xml.etree.ElementTree.Element.text does not conform to the documentation

2015-04-30 Thread Jérôme Laurens
Jérôme Laurens added the comment: The totsstring(..., method='text') is not suitable for the inner text because it adds the tail of the top element. A proper implementation would be def innertext(elt): return (elt.text or '') +''.join(innertext(e)+e.tail for e in elt) that can be

Re: Python is not bad ;-)

2015-04-30 Thread Christian Gollwitzer
Am 30.04.15 um 18:11 schrieb Cecil Westerhof: Op Thursday 30 Apr 2015 16:03 CEST schreef Michael Torrie: On 04/30/2015 01:07 AM, Cecil Westerhof wrote: When I do that the computer is freezed a few times. That is a little less nice. Does not happen with Clojure when it gets an out of memory.

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

2015-04-30 Thread Rob Gaddi
On Thu, 30 Apr 2015 10:05:44 -0700, Gary Herron wrote: On 04/30/2015 09:06 AM, Cecil Westerhof wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have

Re: mixing set and list operations

2015-04-30 Thread Carl Meyer
Hi Tim, On 04/30/2015 10:07 AM, Tim wrote: I noticed this today, using Python2.7 or 3.4, and wondered if it is implementation dependent: You can use 'extend' to add set elements to a list and use 'update' to add list elements to a set. m = ['one', 'two'] p = set(['three', 'four'])

Re: mixing set and list operations

2015-04-30 Thread Ben Finney
Tim jtim.arn...@gmail.com writes: You can use 'extend' to add set elements to a list and use 'update' to add list elements to a set. And you can use both of those methods to add items from a file:: foo = ['one', 'two'] bar = open('/usr/share/common-licenses/GPL-3')

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

2015-04-30 Thread Jon Ribbens
On 2015-04-30, Cecil Westerhof ce...@decebal.nl wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to it. This make those programs more slowly.

[issue24085] large memory overhead when pyc is recompiled

2015-04-30 Thread Buck Evan
New submission from Buck Evan: In the attached example I show that there's a significant memory overhead present whenever a pre-compiled pyc is not present. This only occurs with more than 5225 objects (dictionaries in this case) allocated. At 13756 objects, the mysterious pyc overhead is 50%

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

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 19:12 CEST schreef Rob Gaddi: This also leads to a unrelated question, Cecil. Given that you really are just starting to get your Python feet under you, why are you using Python2? Python3 is the standard now, Python2 is really just given legacy support. I'd understand

Re: Is my implementation of happy number OK

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 19:37 CEST schreef Ian Kelly: Most I still have to digest. ;-) On Thu, Apr 30, 2015 at 9:59 AM, Cecil Westerhof ce...@decebal.nl wrote: return (current_array, ''.join(current_array)) You don't seem to be actually using current_array for anything, so why not just

Re: seek operation in python

2015-04-30 Thread Larry Hudson
On 04/30/2015 01:06 AM, Cecil Westerhof wrote: [snip] I wrote a module where I have: def get_indexed_message(message_filename, index): Get index message from a file, where 0 gets the first message return open(expanduser(message_filename),

Re: Is my implementation of happy number OK

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 20:53 CEST schreef Dave Angel: On 04/30/2015 11:59 AM, Cecil Westerhof wrote: I implemented happy_number function: _happy_set = { '1' } _unhappy_set= set() def happy_number(n): Check if a number is a happy number

Re: Is my implementation of happy number OK

2015-04-30 Thread Dave Angel
On 04/30/2015 11:59 AM, Cecil Westerhof wrote: I implemented happy_number function: _happy_set = { '1' } _unhappy_set= set() def happy_number(n): Check if a number is a happy number https://en.wikipedia.org/wiki/Happy_number

Re: Rounding a number

2015-04-30 Thread Mark Lawrence
On 30/04/2015 21:00, Thijs Engels wrote: On Thu, Apr 30, 2015, at 21:49, Seymore4Head wrote: I have this page book marked. https://mkaz.com/2012/10/10/python-string-format/ I am getting numbers from sixty thousand to two hundred thousand. I would like to round them to the nearest thousand. So

[issue24087] Documentation doesn't explain the term coroutine (PEP 342)

2015-04-30 Thread Paul Moore
New submission from Paul Moore: Although the new generator methods introduced in PEP 342 are documented, the term coroutine is not defined anywhere. In particular, the fact that Python coroutines work in conjunction with an event loop rather than transferring control directly between each

Nuitka Progress in Spring 2015

2015-04-30 Thread Mark Lawrence
Sales and marketing doesn't appear to be Kay Hayen's great strength so I'm taking a massive liberty and flagging Nuitka up here anyway. http://nuitka.net/posts/nuitka-progress-spring-2015.html -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our

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

2015-04-30 Thread Dave Angel
On 04/30/2015 02:48 PM, alister wrote: On Thu, 30 Apr 2015 20:23:31 +0200, Gisle Vanem wrote: Cecil Westerhof wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other

[issue24080] asyncio.Event.wait() Task was destroyed but it is pending

2015-04-30 Thread Marco Paolini
Marco Paolini added the comment: KeyboardInterrupt is not handled gently by asyncio (see https://groups.google.com/d/msg/python-tulip/sovg7EIBoXs/m7U-0UXqzSQJ) you could cancel all tasks in the signal handler: ... def sig_interrupt(): print('interrupt') for task in

[issue24060] Clearify necessities for logging with timestamps

2015-04-30 Thread Vinay Sajip
Vinay Sajip added the comment: Perhaps I'll just change it to say ... the default value of '%(message)s' is used, which just includes the message in the logging call. To have additional items of information in the formatted output (such as a timestamp), see other placeholder variables ...

[issue24085] large memory overhead when pyc is recompiled

2015-04-30 Thread Buck Evan
Buck Evan added the comment: Also, we've reproduced this in both linux and osx. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24085 ___ ___

Re: Lucky numbers in Python

2015-04-30 Thread Cecil Westerhof
Because I want the code to work with Python 3 also, the code is now: def lucky_numbers(n): Lucky numbers from 1 up-to n http://en.wikipedia.org/wiki/Lucky_number if n 3: return [1] sieve = list(range(1, n + 1, 2))

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

2015-04-30 Thread Mark Lawrence
On 30/04/2015 19:50, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 19:12 CEST schreef Rob Gaddi: This also leads to a unrelated question, Cecil. Given that you really are just starting to get your Python feet under you, why are you using Python2? Python3 is the standard now, Python2 is really

Re: Lucky numbers in Python

2015-04-30 Thread Dave Angel
On 04/30/2015 02:55 PM, Cecil Westerhof wrote: Because I want the code to work with Python 3 also, the code is now: def lucky_numbers(n): Lucky numbers from 1 up-to n http://en.wikipedia.org/wiki/Lucky_number if n 3: return [1]

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

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 20:59 CEST schreef Dave Angel: On 04/30/2015 02:48 PM, alister wrote: On Thu, 30 Apr 2015 20:23:31 +0200, Gisle Vanem wrote: Cecil Westerhof wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that

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

2015-04-30 Thread Roel Schroeven
Grant Edwards schreef op 2015-04-30 18:33: On 2015-04-30, Cecil Westerhof ce...@decebal.nl wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to

[issue23495] The writer.writerows method should be documented as accepting any iterable (not only a list)

2015-04-30 Thread Martijn Pieters
Martijn Pieters added the comment: I'd be happy to provide a patch for the DictWriter.writerows code; I was naively counting on it accepting an iterable and that it would not pull the whole sequence into memory (while feeding it gigabytes of CSV data). -- nosy: +mjpieters

Re: Rounding a number

2015-04-30 Thread Thijs Engels
round(65253, -3) might be what you are looking for... On Thu, Apr 30, 2015, at 21:49, Seymore4Head wrote: I have this page book marked. https://mkaz.com/2012/10/10/python-string-format/ I am getting numbers from sixty thousand to two hundred thousand. I would like to round them to the

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

2015-04-30 Thread alister
On Thu, 30 Apr 2015 20:23:31 +0200, Gisle Vanem wrote: Cecil Westerhof wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. The problem is that after this my swap is completely used, because other processes have swapped to it. This make

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

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 19:41 CEST schreef Ben Finney: Cecil Westerhof ce...@decebal.nl writes: That works, yes. Now I get a MemoryError and the other processes are left alone. Now determining what are the best values. I would strongly recommend that “best values” includes “run Python

[issue24085] large memory overhead when pyc is recompiled

2015-04-30 Thread Antoine Pitrou
Antoine Pitrou added the comment: This is transitory memory consumption. Once the source is compiled to bytecode, memory consumption falls down to its previous level. Do you care that much about it? -- nosy: +pitrou ___ Python tracker

Rounding a number

2015-04-30 Thread Seymore4Head
I have this page book marked. https://mkaz.com/2012/10/10/python-string-format/ I am getting numbers from sixty thousand to two hundred thousand. I would like to round them to the nearest thousand. So 65,253 should read 65,000. How? Total=2100 for x in range (10,35): count=1000/x print

Re: Python is not bad ;-)

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 19:59 CEST schreef Christian Gollwitzer: Am 30.04.15 um 18:11 schrieb Cecil Westerhof: Op Thursday 30 Apr 2015 16:03 CEST schreef Michael Torrie: On 04/30/2015 01:07 AM, Cecil Westerhof wrote: When I do that the computer is freezed a few times. That is a little less

[issue24086] Configparser interpolation is unexpected

2015-04-30 Thread Trevor Bekolay
New submission from Trevor Bekolay: I was having an issue installing a package in Python 3, which installed properly in Python 2. This is the error message I got: Complete output from command python setup.py egg_info: Traceback (most recent call last): ... snip unhelpful traceback

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

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 22:53 CEST schreef Mark Lawrence: On 30/04/2015 19:50, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 19:12 CEST schreef Rob Gaddi: This also leads to a unrelated question, Cecil. Given that you really are just starting to get your Python feet under you, why are you

[issue24089] argparse crashes with AssertionError

2015-04-30 Thread SpaceOne
New submission from SpaceOne: Just add an argument with metavar='[PROTOCOL://]HOST[:PORT]' ([...] twice in the string) causes the following traceback: Traceback (most recent call last): File curl.py, line 182, in module arguments = parser.parse_args() File

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

2015-04-30 Thread Steven D'Aprano
On Fri, 1 May 2015 02:06 am, Cecil Westerhof wrote: If I execute: l = range(int(1E9) Others have already answered your questions about memory. Let me answer the question you didn't ask about style :-) Don't use l as a variable name, as it looks too much like 1. Better to use L, or even

Re: Is my implementation of happy number OK

2015-04-30 Thread Cecil Westerhof
Op Friday 1 May 2015 01:52 CEST schreef Dave Angel: On 04/30/2015 07:31 PM, Jon Ribbens wrote: On 2015-04-30, Dave Angel da...@davea.name wrote: Finally, I did some testing on Jon Ribben's version. His was substantially faster for smaller sets, and about the same for 10*7. So it's likely

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

2015-04-30 Thread Cecil Westerhof
Op Friday 1 May 2015 01:12 CEST schreef Ben Finney: Chris Angelico ros...@gmail.com writes: Very easily and simply: Python 3 and Python 2 will always install separately, and the only possible conflicts are over the python command in PATH and which program is associated with .py files.

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

2015-04-30 Thread Cecil Westerhof
Op Friday 1 May 2015 06:42 CEST schreef Steven D'Aprano: On Fri, 1 May 2015 02:06 am, Cecil Westerhof wrote: If I execute: l = range(int(1E9) Others have already answered your questions about memory. Let me answer the question you didn't ask about style :-) That can be very useful.

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

2015-04-30 Thread Mark Lawrence
On 01/05/2015 05:19, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 22:53 CEST schreef Mark Lawrence: On 30/04/2015 19:50, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 19:12 CEST schreef Rob Gaddi: This also leads to a unrelated question, Cecil. Given that you really are just starting to

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

2015-04-30 Thread Steven D'Aprano
On Fri, 1 May 2015 03:20 am, Ben Finney wrote: Jon Ribbens jon+use...@unequivocal.co.uk writes: On 2015-04-30, Cecil Westerhof ce...@decebal.nl wrote: If I execute: l = range(int(1E9) The python process gobbles up all the memory and is killed. […] Is there a way to circumvent Python

Re: Nuitka Progress in Spring 2015

2015-04-30 Thread Ben Finney
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: On Fri, 1 May 2015 07:01 am, Mark Lawrence wrote: http://nuitka.net/posts/nuitka-progress-spring-2015.html Anyone care to summarise the highlights Nuitka Progress in Spring 2015 * SSA (Single State Assignment Form): will allow

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

2015-04-30 Thread Cecil Westerhof
Op Thursday 30 Apr 2015 23:41 CEST schreef Tim Chase: On 2015-04-30 22:18, Cecil Westerhof wrote: Op Thursday 30 Apr 2015 20:59 CEST schreef Dave Angel: ulimit is your friend if you've got a program that wants to gobble up all of swap space. Yes, my system is openSUSE 64 bit. I really

Re: Nuitka Progress in Spring 2015

2015-04-30 Thread Steven D'Aprano
On Fri, 1 May 2015 07:01 am, Mark Lawrence wrote: Sales and marketing doesn't appear to be Kay Hayen's great strength so I'm taking a massive liberty and flagging Nuitka up here anyway. http://nuitka.net/posts/nuitka-progress-spring-2015.html Anyone care to summarise the highlights for

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

2015-04-30 Thread Chris Angelico
On Fri, May 1, 2015 at 7:23 AM, ElChino elch...@cnn.cn wrote: Mark Lawrence wrote: You might find this useful then in you haven't already seen it https://docs.python.org/3/howto/pyporting.html The main reason I haven't switched to Python3 (from 2.7.4/MSVC), is fear of a major breakage. How

[issue2651] Strings passed to KeyError do not round trip

2015-04-30 Thread Łukasz Langa
Łukasz Langa added the comment: Agreed that this can be addressed now for Python 3.5. -- assignee: - lukasz.langa versions: +Python 3.5 -Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2651

[issue24085] large memory overhead when pyc is recompiled

2015-04-30 Thread Anthony Sottile
Anthony Sottile added the comment: Adding `import gc; gc.collect()` doesn't change the outcome afaict -- nosy: +asottile ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24085 ___

  1   2   >