Re: Efficency help for a Calculator Program

2013-10-03 Thread Chris Angelico
On Fri, Oct 4, 2013 at 9:15 AM, Dennis Lee Bieber wrote: > On Thu, 3 Oct 2013 10:25:47 +1000, Chris Angelico > declaimed the following: > >>On Thu, Oct 3, 2013 at 9:47 AM, Dennis Lee Bieber >>wrote: >>> try: >>> numItems = int(raw_input("\n\nHow many values? ")) >>> except:

Re: compare two list of dictionaries

2013-10-03 Thread Mohan L
On Fri, Oct 4, 2013 at 12:14 AM, MRAB wrote: > On 03/10/2013 17:11, Mohan L wrote: > >> Dear All, >> >> I have two list of dictionaries like below: >> >> In the below dictionaries the value of ip can be either hostname or ip >> address. >> >> output1=[ >> {'count': 3 , 'ip': 'xxx.xx.xxx.1'}, >> {

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread Steven D'Aprano
On Thu, 03 Oct 2013 10:09:25 -0400, random832 wrote: > Speaking of assumptions, I would almost say that we should make the > assumption that operators (other than the __i family, and > setitem/setattr/etc) are not intended to have visible side effects. This > would open a _huge_ field of potential

Re: Goodbye: was JUST GOT HACKED

2013-10-03 Thread Steven D'Aprano
On Thu, 03 Oct 2013 17:31:44 +0530, Ravi Sahni wrote: > On Thu, Oct 3, 2013 at 5:05 PM, Steven D'Aprano > wrote: >> No, you are welcome here. You've posted more in just a few days than >> Walter has in months. We need more people like you. > > Thanks for the welcome! > > But No thanks for the

Re: Literal syntax for frozenset, frozendict

2013-10-03 Thread Ethan Furman
On 10/03/2013 05:18 PM, Ben Finney wrote: random...@fastmail.us writes: Hey, while we're on the subject, can we talk about frozen(set|dict) literals again? I really don't understand why this discussion fizzles out whenever it's brought up on python-ideas. Can you start us off by searching for

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread Steven D'Aprano
On Wed, 02 Oct 2013 22:41:00 -0400, Terry Reedy wrote: > I am referring to constant-value objects included in the code object. > >>> def f(): return (1,2,3) > > >>> f.__code__.co_consts > (None, 1, 2, 3, (1, 2, 3)) Okay, now that's more clear. I didn't understand what you meant before. So lon

Literal syntax for frozenset, frozendict (was: Tail recursion to while iteration in 2 easy steps)

2013-10-03 Thread Ben Finney
random...@fastmail.us writes: > Hey, while we're on the subject, can we talk about frozen(set|dict) > literals again? I really don't understand why this discussion fizzles > out whenever it's brought up on python-ideas. Can you start us off by searching for previous threads discussing it, and sum

Re: Multiple scripts versus single multi-threaded script

2013-10-03 Thread Chris Angelico
On Fri, Oct 4, 2013 at 5:53 AM, Roy Smith wrote: > So, I think my original statement: > >> if you're looking for a short answer, I'd say just keep doing what >> you're doing using multiple processes and don't get into threading. > > is still good advice for somebody who isn't sure they need thread

Re: wil anyone ressurect medusa and pypersist?

2013-10-03 Thread c-gschuette
On Thursday, May 16, 2013 11:15:45 AM UTC-7, vispha...@gmail.com wrote: > www.prevayler.org in python = pypersist > > > > medusa = python epoll web server and ftp server eventy and async wow interesting sprevayler ?? cl-prevalence -- https://mail.python.org/mailman/listinfo/python-list

Re: Multiple scripts versus single multi-threaded script

2013-10-03 Thread Roy Smith
In article , Chris Angelico wrote: > As to your corrupt data example, though, I'd advocate a very simple > system of object ownership: as soon as the object has been put on the > queue, it's "owned" by the recipient and shouldn't be mutated by > anyone else. Well, sure. I agree with you that t

Re: ipy %run noob confusion

2013-10-03 Thread Mark Lawrence
On 03/10/2013 20:26, Terry Reedy wrote: On 10/3/2013 1:42 PM, jshra...@gmail.com wrote: I have some rather complex code that works perfectly well if I paste it in by hand to ipython, but if I use %run it can't find some of the libraries, but others it can. Ipython is a separate product built o

Re: ipy %run noob confusion

2013-10-03 Thread Terry Reedy
On 10/3/2013 1:42 PM, jshra...@gmail.com wrote: I have some rather complex code that works perfectly well if I paste it in by hand to ipython, but if I use %run it can't find some of the libraries, but others it can. Ipython is a separate product built on top of Python. If no answer here, lo

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread Terry Reedy
On 10/2/2013 10:34 PM, Steven D'Aprano wrote: You are both assuming that LOAD_CONST will re-use the same tuple (1, 2, 3) in multiple places. No I did not. To save tuple creation time, a pre-compiled tuple is reused when its display expression is re-executed. If I had been interested in multi

Re: compare two list of dictionaries

2013-10-03 Thread MRAB
On 03/10/2013 17:11, Mohan L wrote: Dear All, I have two list of dictionaries like below: In the below dictionaries the value of ip can be either hostname or ip address. output1=[ {'count': 3 , 'ip': 'xxx.xx.xxx.1'}, {'count': 4, 'ip': 'xxx.xx.xxx.2'}, {'count': 8, 'ip': 'xxx.xx.xxx.3'}, {'cou

Re: Multiple scripts versus single multi-threaded script

2013-10-03 Thread Dave Angel
On 3/10/2013 12:50, Chris Angelico wrote: > On Fri, Oct 4, 2013 at 2:41 AM, Roy Smith wrote: >> The downside to threads is that all of of this sharing makes them much >> more complicated to use properly. You have to be aware of how all the >> threads are interacting, and mediate access to shared

Re: Multiple scripts versus single multi-threaded script

2013-10-03 Thread Chris Angelico
On Fri, Oct 4, 2013 at 4:28 AM, Roy Smith wrote: > Well, the GIL certainly eliminates a whole range of problems, but it's > still possible to write code that deadlocks. All that's really needed > is for two threads to try to acquire the same two resources, in > different orders. I'm running the

Re: Multiple scripts versus single multi-threaded script

2013-10-03 Thread Roy Smith
In article , Chris Angelico wrote: > On Fri, Oct 4, 2013 at 2:41 AM, Roy Smith wrote: > > The downside to threads is that all of of this sharing makes them much > > more complicated to use properly. You have to be aware of how all the > > threads are interacting, and mediate access to shared r

Re: Why didn't my threads exit correctly ?

2013-10-03 Thread MRAB
On 03/10/2013 18:37, 李洛 wrote: Hi list, I write an example script using threading as follow. It look like hang when the list l_ip is empty. And any suggestion with debug over the threading in Python ? 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 import re 4 import os 5 impo

Re: Rounding off Values of dicts (in a list) to 2 decimal points

2013-10-03 Thread tripsvt
On Thursday, October 3, 2013 11:03:17 AM UTC-7, Neil Cerutti wrote: > On 2013-10-03, trip...@gmail.com wrote: > > > thekey=[{"a": 80.0, "b": 0.0, "c": 10.0, "d": 10.0}, {"a": > > > 100.0, "b": 0.0, "c": 0.0, "d": 0.0}, {"a": 80.0, "b": 0.0, > > > "c": 10.0, "d": 10.0}, {"a": 90.0, "b": 0.0, "c"

Re: Get the selected tab in a enthought traits application

2013-10-03 Thread petmertens
Here's the answer: from enthought.traits.api import HasTraits, Str, List, Button, Any from enthought.traits.ui.api import View, Item from enthought.traits.ui.api import ListEditor class A(HasTraits): StringA = Str view = View(Item('StringA')) class B(HasTraits): StringB = Str view

Re: Rounding off Values of dicts (in a list) to 2 decimal points

2013-10-03 Thread Neil Cerutti
On 2013-10-03, trip...@gmail.com wrote: > thekey=[{"a": 80.0, "b": 0.0, "c": 10.0, "d": 10.0}, {"a": > 100.0, "b": 0.0, "c": 0.0, "d": 0.0}, {"a": 80.0, "b": 0.0, > "c": 10.0, "d": 10.0}, {"a": 90.0, "b": 0.0, "c": 0.0, "d": > 10.0}] > > However, at the URL, the values show up as 90.4327869412

Why didn't my threads exit correctly ?

2013-10-03 Thread 李洛
Hi list, I write an example script using threading as follow. It look like hang when the list l_ip is empty. And any suggestion with debug over the threading in Python ? 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 import re 4 import os 5 import threading 6 from Queue import Que

compare two list of dictionaries

2013-10-03 Thread Mohan L
Dear All, I have two list of dictionaries like below: In the below dictionaries the value of ip can be either hostname or ip address. output1=[ {'count': 3 , 'ip': 'xxx.xx.xxx.1'}, {'count': 4, 'ip': 'xxx.xx.xxx.2'}, {'count': 8, 'ip': 'xxx.xx.xxx.3'}, {'count': 10, 'ip': 'xxx.xx.xxx.4'}, {'coun

Re: feature requests

2013-10-03 Thread Ethan Furman
On 10/03/2013 09:12 AM, macker wrote: Hi, hope this is the right group for this: I miss two basic (IMO) features in parallel processing: 1. make `threading.Thread.start()` return `self` I'd like to be able to `workers = [Thread(params).start() for params in whatever]`. Right now, it's 5 ugly,

ipy %run noob confusion

2013-10-03 Thread jshrager
I have some rather complex code that works perfectly well if I paste it in by hand to ipython, but if I use %run it can't find some of the libraries, but others it can. The confusion seems to have to do with mathplotlib. I get it in stream by: %pylab osx and do a bunch of stuff interactivel

Re: Rounding off Values of dicts (in a list) to 2 decimal points

2013-10-03 Thread Peter Otten
trip...@gmail.com wrote: > On Wednesday, October 2, 2013 10:01:16 AM UTC-7, tri...@gmail.com wrote: >> am trying to round off values in a dict to 2 decimal points but have been >> unsuccessful so far. The input I have is like this: >> >> >> >> >> >> y = [{'a': 80.0, 'b': 0.0786235, 'c': 1

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread Ravi Sahni
On Wed, Oct 2, 2013 at 10:46 AM, rusi wrote: > 4. There is a whole spectrum of such optimizaitons -- > 4a eg a single-call structural recursion example, does not need to push > return address on the stack. It only needs to store the recursion depth: > > If zero jump to outside return add; if > 0 j

Re: Rounding off Values of dicts (in a list) to 2 decimal points

2013-10-03 Thread tripsvt
On Wednesday, October 2, 2013 10:01:16 AM UTC-7, tri...@gmail.com wrote: > am trying to round off values in a dict to 2 decimal points but have been > unsuccessful so far. The input I have is like this: > > > > > > y = [{'a': 80.0, 'b': 0.0786235, 'c': 10.0, 'd': 10.6742903}, {'a': > 80.

Re: Multiple scripts versus single multi-threaded script

2013-10-03 Thread Chris Angelico
On Fri, Oct 4, 2013 at 2:41 AM, Roy Smith wrote: > The downside to threads is that all of of this sharing makes them much > more complicated to use properly. You have to be aware of how all the > threads are interacting, and mediate access to shared resources. If you > do that wrong, you get mem

Re: Multiple scripts versus single multi-threaded script

2013-10-03 Thread Chris Angelico
On Fri, Oct 4, 2013 at 2:01 AM, JL wrote: > What is the difference between running multiple python scripts and a single > multi-threaded script? May I know what are the pros and cons of each > approach? Right now, my preference is to run multiple separate python scripts > because it is simpler.

Re: feature requests

2013-10-03 Thread Chris Angelico
On Fri, Oct 4, 2013 at 2:42 AM, Tim Chase wrote: > Do you mean > > workers = [Thread(params) for params in whatever] > for thrd in workers: thrd.start() > > ? ("Thread(params)" vs. "Thread(params).start()" in your list comp) Whoops, copy/paste fail. Yes, that's what I meant. Thanks for catc

Re: feature requests

2013-10-03 Thread Tim Chase
On 2013-10-04 02:21, Chris Angelico wrote: > > workers = [] > > for params in whatever: > > thread = threading.Thread(params) > > thread.start() > > workers.append(thread) > > You could shorten this by iterating twice, if that helps: > > worke

Re: Multiple scripts versus single multi-threaded script

2013-10-03 Thread Roy Smith
In article , JL wrote: > What is the difference between running multiple python scripts and a single > multi-threaded script? May I know what are the pros and cons of each > approach? Right now, my preference is to run multiple separate python scripts > because it is simpler. First, let's ta

Re: feature requests

2013-10-03 Thread Chris Angelico
On Fri, Oct 4, 2013 at 2:12 AM, macker wrote: > I'd like to be able to `workers = [Thread(params).start() for params in > whatever]`. Right now, it's 5 ugly, menial lines: > > workers = [] > for params in whatever: > thread = threading.Thread(params) > thre

feature requests

2013-10-03 Thread macker
Hi, hope this is the right group for this: I miss two basic (IMO) features in parallel processing: 1. make `threading.Thread.start()` return `self` I'd like to be able to `workers = [Thread(params).start() for params in whatever]`. Right now, it's 5 ugly, menial lines: workers = []

Re: [Python-Dev] summing integer and class

2013-10-03 Thread Chris Kaynor
This list is for development OF Python, not for development in python. For that reason, I will redirect this to python-list as well. My actual answer is below. On Thu, Oct 3, 2013 at 6:45 AM, Igor Vasilyev wrote: > Hi. > > Example test.py: > > class A(): > def __add__(self, var): >

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread Neil Cerutti
On 2013-10-03, Duncan Booth wrote: >> How do know that either "<=" or "*" didn't rebind the name >> "fact" to something else? I think that's the main reason why >> python cannot apply any procedural optimization (even things >> like inlining are impossible, or possible only under very >> conservat

Multiple scripts versus single multi-threaded script

2013-10-03 Thread JL
What is the difference between running multiple python scripts and a single multi-threaded script? May I know what are the pros and cons of each approach? Right now, my preference is to run multiple separate python scripts because it is simpler. -- https://mail.python.org/mailman/listinfo/pytho

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread Duncan Booth
Alain Ketterlin wrote: > Terry Reedy writes: > >> Part of the reason that Python does not do tail call optimization is >> that turning tail recursion into while iteration is almost trivial, >> once you know the secret of the two easy steps. Here it is. >> >> Assume that you have already done th

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread random832
On Wed, Oct 2, 2013, at 22:34, Steven D'Aprano wrote: > You are both assuming that LOAD_CONST will re-use the same tuple > (1, 2, 3) in multiple places. But that's not the case, as a simple test > will show you: >>> def f(): ... return (1, 2, 3) >>> f() is f() True It does, in fact, re-use it

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread random832
On Wed, Oct 2, 2013, at 21:46, MRAB wrote: > > The difference is that a tuple can be reused, so it makes sense for the > > comiler to produce it as a const. (Much like the interning of small > > integers) The list, however, would always have to be copied from the > > compile-time object. So that

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread random832
On Wed, Oct 2, 2013, at 17:33, Terry Reedy wrote: > 5. Conversion of apparent recursion to iteration assumes that the > function really is intended to be recursive. This assumption is the > basis for replacing the recursive call with assignment and an implied > internal goto. The programmer can

Re: Goodbye: was JUST GOT HACKED

2013-10-03 Thread Ravi Sahni
On Thu, Oct 3, 2013 at 5:05 PM, Steven D'Aprano wrote: > On Thu, 03 Oct 2013 09:21:08 +0530, Ravi Sahni wrote: > >> On Thu, Oct 3, 2013 at 2:43 AM, Walter Hurry >> wrote: >>> Ding ding! Nikos is simply trolling. It's easy enough to killfile him >>> but inconvenient to skip all the answers to his

Re: JUST GOT HACKED

2013-10-03 Thread Steven D'Aprano
On Thu, 03 Oct 2013 09:01:29 +0200, Antoon Pardon wrote: > You don't > follow the principle of treating others in the way you hope to be > treated if you were in their shoes. [...] > Suppose you develop a new > interest in which you are now the newbie and you go to a newsgroup or > forum where a

Re: Goodbye: was JUST GOT HACKED

2013-10-03 Thread Steven D'Aprano
On Thu, 03 Oct 2013 09:21:08 +0530, Ravi Sahni wrote: > On Thu, Oct 3, 2013 at 2:43 AM, Walter Hurry > wrote: >> Ding ding! Nikos is simply trolling. It's easy enough to killfile him >> but inconvenient to skip all the answers to his lengthy threads. If >> only people would just ignore him! > >

Re: Lowest Value in List

2013-10-03 Thread Peter Otten
subhabangal...@gmail.com wrote: > Dear Group, > > I am trying to work out a solution to the following problem in Python. > > The Problem: > Suppose I have three lists. > Each list is having 10 elements in ascending order. > I have to construct one list having 10 elements which are of the lowest

Re: Running code from source that includes extension modules

2013-10-03 Thread Oscar Benjamin
On 2 October 2013 23:28, Michael Schwarz wrote: > > I will look into that too, that sounds very convenient. But am I right, that > to use Cython the non-Python code needs to be written in the Cython language, > which means I can't just copy&past C code into it? For my current project, > this is

Nodebox(v1) on the web via RapydScript

2013-10-03 Thread Salvatore DI DIO
Hello, Nodebox is a program in the spirit of Processing but for Python. The first version runs only on MAC. Tom, the creator has partly ported it to Javascript. But many of you dislike Javascript. The solution was to use a translator, Python -> Javascript Of the both two greats solutions Bryth

Re: JUST GOT HACKED

2013-10-03 Thread Antoon Pardon
Op 02-10-13 15:17, Steven D'Aprano schreef: > [...] >> And you don't treat all others in the way you hope to be treated if you >> would be in their shoes. I suspect that should you one day feel so >> frustrated you need to vent, you will hope to get treated differently >> than how you treat those