Re: Comparisons and sorting of a numeric class....

2015-01-14 Thread Andrew Robinson
And most of this thread has been nothing more than me asking "why" did Guido say to do that -- and people avoiding answering the question. Wait, are you actually asking why bool is a doubleton? If nobody has answered that, I think probably nobody understood you were asking it, because it shoul

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Frank Millman
"Dennis Lee Bieber" wrote in message news:1j1ebalmgkuskq0ltnv5m4sbm6d3p5f...@4ax.com... > > Pseudo (Python 2.x) code > > def aThread(delay=600.0): #default 10 minutes > while keepRunning: > print "thread triggered at %s" % time.time() > time.sleep(delay) > print "thread w

Re: lambdak: multi-line lambda implementation in native Python

2015-01-14 Thread Ian Kelly
On Wed, Jan 14, 2015 at 11:06 PM, Steven D'Aprano wrote: > I have a function, which I put into an expression like this: > > def func(a, b=None): > global spam > import math > spam = [a, b]*3 > print spam > del spam > > > value = [1, "hello", int, func] > del func > > How would

Re: lambdak: multi-line lambda implementation in native Python

2015-01-14 Thread Steven D'Aprano
On Wed, 14 Jan 2015 21:54:52 -0800, yawar.amin wrote: > Now, the crux of my message. I have implemented what I believe is a > fairly robust, if ugly-looking, native Python module made up of > combinator functions which compose together to form function expressions > (well, callable expressions).

Re: type versus __class__

2015-01-14 Thread Ian Kelly
On Wed, Jan 14, 2015 at 6:26 PM, Steven D'Aprano wrote: > Any other differences? Objects of classic builtin types don't even have the __class__ attribute. >>> type(A) >>> A.__class__ Traceback (most recent call last): File "", line 1, in AttributeError: class A has no attribute '__class__' >

lambdak: multi-line lambda implementation in native Python

2015-01-14 Thread yawar . amin
Hi all, First off, to each reader--if you believe that 'multi-line' lambdas are no good and we can just use functions, decorators, &c. to accomplish everything in Python, advance warning: this post will annoy you. Now, the crux of my message. I have implemented what I believe is a fairly robust,

Re: Comparisons and sorting of a numeric class....

2015-01-14 Thread Ian Kelly
On Wed, Jan 14, 2015 at 8:00 PM, Andrew Robinson wrote: > Hi Ian, > On 01/14/2015 12:31 AM, Ian Kelly wrote: > > On Tue, Jan 13, 2015 at 5:12 PM, Andrew Robinson > wrote: > > So -- even a cursory thought shows that the information could be encoded in > a very few lines even without an instance of

Re: Python 3 regex?

2015-01-14 Thread Rustom Mody
On Tuesday, January 13, 2015 at 10:06:50 AM UTC+5:30, Steven D'Aprano wrote: > On Mon, 12 Jan 2015 19:48:18 +, Ian wrote: > > > My recommendation would be to write a recursive decent parser for your > > files. > > > > That way will be easier to write, > > I know that writing parsers is a sol

Re: Python 3 regex?

2015-01-14 Thread Rustom Mody
On Tuesday, January 13, 2015 at 10:06:50 AM UTC+5:30, Steven D'Aprano wrote: > On Mon, 12 Jan 2015 19:48:18 +, Ian wrote: > > > My recommendation would be to write a recursive decent parser for your > > files. > > > > That way will be easier to write, > > I know that writing parsers is a sol

Re: Calling a derived class's constructor from a parent method

2015-01-14 Thread Mark Lawrence
On 15/01/2015 00:40, Steven D'Aprano wrote: jason wrote: class B(A): def __init__(self, s): A.__init__(self, s) Unrelated: It is better to call super than manually call the superclass. Calling A directly means your class is no longer compatible with multiple inheritance.

Re: List of "python -m" tools

2015-01-14 Thread alex23
On 14/01/2015 7:33 PM, Albert-Jan Roskam wrote: You say "Python 2.7.9 and 3.x comes with an easy way to install pip. Run python -m ensurepip and pypi is at your service." . But here https://docs.python.org/3/library/ensurepip.html it says that "This module does not access the internet. All of t

Re: Performance in exec environnements

2015-01-14 Thread Steven D'Aprano
Jean-Baptiste Braun wrote: > 2015-01-13 22:48 GMT+01:00 Steven D'Aprano < > steve+comp.lang.pyt...@pearwood.info>: > >> So you have been comparing: >> >> 2 >> >> versus >> >> exec('1+1') >> >> >> The first case just fetches a reference to a pre-existing int object, and >> then deletes the

type versus __class__

2015-01-14 Thread Steven D'Aprano
There are (at least) two ways to determine the type of something in Python: type(obj) obj.__class__ By design, they are not guaranteed to give the same result. Is there a definitive explanation given by the docs for the difference and which you should use under different circumstances? In Py

Re: Calling a derived class's constructor from a parent method

2015-01-14 Thread Steven D'Aprano
jason wrote: > If I have a class hierarchy like so: > > > class A(object): > def __init__(self, s): > self.s = s > def foo(self, s): > return A(s) A.foo is broken, or at least rude. Change it to this: def foo(self, s): return type(self)(s) >

Re: Python 3 regex?

2015-01-14 Thread Steven D'Aprano
Thomas 'PointedEars' Lahn wrote: > wxjmfa...@gmail.com wrote: [...] >> And, why not? compare Py3.2 and Py3.3+ ! > > What are you getting at? Don't waste your time with JMF. He is obsessed with a trivial performance regression in Python 3.3. Unicode strings can be slightly more expensive to crea

Re: multiprocessing queue hangs up on the Amazon cloud

2015-01-14 Thread Chris Kaynor
On Wed, Jan 14, 2015 at 2:16 PM, Chris Angelico wrote: > And then you seek to run multiple workers. If my reading is correct, > one of them (whichever one happens to get there first) will read the > STOP marker and finish; the others will all be blocked, waiting for > more work (which will never

Re: multiprocessing queue hangs up on the Amazon cloud

2015-01-14 Thread Chris Angelico
On Thu, Jan 15, 2015 at 8:55 AM, wrote: > I am trying to run a series of scripts on the Amazon cloud, multiprocessing > on the 32 cores of our AWS instance. The scripts run well, and the queuing > seems to work BUT, although the processes run to completion, the script below > that runs the qu

multiprocessing queue hangs up on the Amazon cloud

2015-01-14 Thread jgrant
Hello! I searched and found posts that were similar to mine, but either I couldn't understand the answer or the problem was different enough that the answers weren't helpful - please excuse me if this seems to repeat a problem already answered. I am trying to run a series of scripts on the Ama

Re: Compiling multiple python scripts into an exe file

2015-01-14 Thread Dan Stromberg
On Tue, Jan 13, 2015 at 10:53 PM, dieter wrote: > no nein writes: > >> Basically, is it possible to compile multiple unrelated python scripts into >> a single exe file, so when execute it several python programs are run at >> once. > > These are two distinct problems: > > * for doing things

Re: Threading in Python, Please check the script

2015-01-14 Thread sohcahtoa82
On Tuesday, January 13, 2015 at 10:22:32 PM UTC-8, Robert Clove wrote: > Hi All, > > I have made a script in which i have started two thread named thread 1 and > thread 2. > In thread 1 one function will run named func1 and in thread 2 function 2 will > run named func 2. > Thread 1 will execute

Re: Calling a derived class's constructor from a parent method

2015-01-14 Thread Dave Angel
On 01/14/2015 01:10 PM, jason wrote: On Wednesday, January 14, 2015 at 12:05:55 PM UTC-5, Mark Lawrence wrote: I'm confused, can you please explain what you're trying to achieve rather than how you're trying to achieve it and I'm sure that others will give better answers than I can :) Good c

Re: Calling a derived class's constructor from a parent method

2015-01-14 Thread alister
On Wed, 14 Jan 2015 17:05:27 +, Mark Lawrence wrote: > On 14/01/2015 16:45, jason wrote: >> If I have a class hierarchy like so: >> >> >> class A(object): >>def __init__(self, s): >> self.s = s >>def foo(self, s): >> return A(s) >> >> class B(A): >>

Re: Calling a derived class's constructor from a parent method

2015-01-14 Thread jason
On Wednesday, January 14, 2015 at 12:05:55 PM UTC-5, Mark Lawrence wrote: > I'm confused, can you please explain what you're trying to achieve > rather than how you're trying to achieve it and I'm sure that others > will give better answers than I can :) > Good call. Coming up with a minimal

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Grant Edwards
On 2015-01-14, Mark Lawrence wrote: > On 14/01/2015 17:37, Grant Edwards wrote: >> On 2015-01-14, Mark Lawrence wrote: >> >>> Reminds me of working on Telematics S200/300/4000/5000 telecomms kit in >>> the early 90s where the timers were mains based, so a one hour timer >>> would go off at about

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Mark Lawrence
On 14/01/2015 17:37, Grant Edwards wrote: On 2015-01-14, Mark Lawrence wrote: On 14/01/2015 16:33, Dave Angel wrote: Note that neither Timer nor sleep makes any promises about how accurately it matches the requested time. Reminds me of working on Telematics S200/300/4000/5000 telecomms kit

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Grant Edwards
On 2015-01-14, Mark Lawrence wrote: > On 14/01/2015 16:33, Dave Angel wrote: > >> Note that neither Timer nor sleep makes any promises about how >> accurately it matches the requested time. > > Reminds me of working on Telematics S200/300/4000/5000 telecomms kit in > the early 90s where the timer

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
> Do you want to fix the symptom, fix the problem, or finish a school > assignment? To do the first, make a global variable that contains the time > you want to stop making new threads, and conditionally test it before > calling threading.Timer > I firstly apologise for multiple posts and thanks

Re: [ANN] EasyGUI_Qt version 0.9

2015-01-14 Thread stephen . boulet
On Tuesday, January 13, 2015 at 8:30:13 PM UTC, André Roberge wrote: > On Tuesday, 13 January 2015 08:23:30 UTC-4, stephen...@gmail.com wrote: > > I found a solution that I'm happy with. > > > > from datetime import datetime > > from easygui_qt import * > > > > datestring = get_date() > > mydate

Re: Performance in exec environnements

2015-01-14 Thread Ian Kelly
On Wed, Jan 14, 2015 at 2:02 AM, Jean-Baptiste Braun wrote: > What I don't understand is the ratio between test 2 / 4 and test 1 / 3. > > Let 0.0229 sec be the execution time to read a bytecode (1st test). > Executing two times that bytecode takes 0.042 sec (test 3), which looks > coherent. > > Le

Re: Calling a derived class's constructor from a parent method

2015-01-14 Thread Mark Lawrence
On 14/01/2015 16:45, jason wrote: If I have a class hierarchy like so: class A(object): def __init__(self, s): self.s = s def foo(self, s): return A(s) class B(A): def __init__(self, s): A.__init__(self, s) If I make a B: b = B(0)

Re: Calling a derived class's constructor from a parent method

2015-01-14 Thread Chris Angelico
On Thu, Jan 15, 2015 at 3:45 AM, jason wrote: > If I have a class hierarchy like so: > > > class A(object): > def __init__(self, s): > self.s = s > def foo(self, s): > return A(s) > > class B(A): > def __init__(self, s): > A.__init__(self, s) >

Re: Calling a derived class's constructor from a parent method

2015-01-14 Thread Ian Kelly
On Wed, Jan 14, 2015 at 9:45 AM, jason wrote: > class A(object): > def __init__(self, s): > self.s = s > def foo(self, s): > return A(s) Instead of explicitly naming the return class here, do this: return self.__class__(s) Alternatively, since you never u

Calling a derived class's constructor from a parent method

2015-01-14 Thread jason
If I have a class hierarchy like so: class A(object): def __init__(self, s): self.s = s def foo(self, s): return A(s) class B(A): def __init__(self, s): A.__init__(self, s) If I make a B: b = B(0) I'd like b.foo(1) to return an instance o

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Mark Lawrence
On 14/01/2015 16:33, Dave Angel wrote: Note that neither Timer nor sleep makes any promises about how accurately it matches the requested time. Reminds me of working on Telematics S200/300/4000/5000 telecomms kit in the early 90s where the timers were mains based, so a one hour timer would

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Dave Angel
On 01/14/2015 08:09 AM, Ganesh Pal wrote: Corrected Typos . a) How to I prevent the execution of Print "EXECUTED SLEEP" after 4 seconds ? , current this is running in an infinite loop Please on't top-post. If you want to comment on a message, insert your comments after the portion of

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Mark Lawrence
On 14/01/2015 15:03, Ganesh Pal wrote: This is bit urgent and I all stuck form last few hours :( I'm not inclined to help a person who throws four posts at us in two hours and top posts, sorry. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our

Re: Python 3 regex?

2015-01-14 Thread alister
On Wed, 14 Jan 2015 14:02:27 +0100, Thomas 'PointedEars' Lahn wrote: > wxjmfa...@gmail.com wrote: > >> Le mardi 13 janvier 2015 03:53:43 UTC+1, Rick Johnson a écrit : >>> [...] >>> you should find Python's "text processing Nirvana" >>> [...] >> >> I recommend, you write a "small" application >

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
This is bit urgent and I all stuck form last few hours :( On Wed, Jan 14, 2015 at 6:37 PM, Ganesh Pal wrote: > Iam using Linux and Python 2.7 and playing with the threading.Timer module. > > I had the below question on the same. > > (a) How to I prevent the execution the "EXECUTED SLEEP" af

Re: what would be the regular expression for null byte present in a string

2015-01-14 Thread Wolfgang Maier
On 01/13/2015 02:40 PM, Shambhu Rajak wrote: I have a string that I get as an output of a command as: '\x01\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00*10232ae8944a*\x02\x00\x00\x00\x00\x00\x00\x00\n' I want to fetch ‘*10232ae8944a*’ from the above string. I want to find a re pattern that coul

Re: what would be the regular expression for null byte present in a string

2015-01-14 Thread Wolfgang Maier
On 01/13/2015 02:40 PM, Shambhu Rajak wrote: I have a string that I get as an output of a command as: '\x01\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x0010232ae8944a\x02\x00\x00\x00\x00\x00\x00\x00\n' I want to fetch ‘*10232ae8944a*’ from the above string. I want to find a re pattern that could

Re: what would be the regular expression for null byte present in a string

2015-01-14 Thread Thomas 'PointedEars' Lahn
Thomas 'PointedEars' Lahn wrote: > Peter Otten wrote: >> Shambhu Rajak wrote: >>> I want to find a re pattern that could replace all the \x01..\x0z to be >>> replace by empty string '', so that I can get the desired portion of >>> string >>> >>> Can anyone help me with a working regex for it. >>

Re: what would be the regular expression for null byte present in a string

2015-01-14 Thread Thomas 'PointedEars' Lahn
Peter Otten wrote: > Shambhu Rajak wrote: >> I have a string that I get as an output of a command as: >> > '\x01\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x0010232ae8944a\x02\x00\x00\x00\x00\x00\x00\x00\n' >> >> I want to fetch '10232ae8944a' from the above string. >> >> I want to find a re patt

Re: what would be the regular expression for null byte present in a string

2015-01-14 Thread Thomas 'PointedEars' Lahn
Shambhu Rajak wrote: > I have a string that I get as an output of a command as: > '\x01\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x0010232ae8944a\x02\x00\x00\x00\x00\x00\x00\x00\n' > > I want to fetch '10232ae8944a' from the above string. > > I want to find a re pattern that could replace all the

Re: Performance in exec environnements

2015-01-14 Thread Chris Angelico
On Thu, Jan 15, 2015 at 12:38 AM, Jean-Baptiste Braun wrote: > 2015-01-14 12:14 GMT+01:00 Chris Angelico : >> >> Would it be possible to do a one-off transformation of the entire XSLT >> file into a Python module with a single function in it, and then every >> time you need that XSLT, you import t

Re: Performance in exec environnements

2015-01-14 Thread Jean-Baptiste Braun
2015-01-14 12:14 GMT+01:00 Chris Angelico : > Would it be possible to do a one-off transformation of the entire XSLT > file into a Python module with a single function in it, and then every > time you need that XSLT, you import that module and call the function? > That would potentially be a lot q

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
I quick modified the code and it now looks like this ,is this ok for termination ? I played with t.canel() it didn't work import threading import time def printit(): print "EXECUTED SLEEP" t = threading.Timer(4, printit) t.start() printit() print "hello" output : Throttling-1# python f

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
Corrected Typos . >a) How to I prevent the execution of Print "EXECUTED SLEEP" after 4 > seconds ? , current this is running in an infinite loop On Wed, Jan 14, 2015 at 6:37 PM, Ganesh Pal wrote: > Iam using Linux and Python 2.7 and playing with the threading.Timer module. > > I had the be

How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
Iam using Linux and Python 2.7 and playing with the threading.Timer module. I had the below question on the same. (a) How to I prevent the execution the "EXECUTED SLEEP" after 4 seconds ? , current this is running in an infinite loop node-1# cat file_01.py import threading import time def

Re: Python 3 regex?

2015-01-14 Thread Thomas 'PointedEars' Lahn
wxjmfa...@gmail.com wrote: > Le mardi 13 janvier 2015 03:53:43 UTC+1, Rick Johnson a écrit : >> [...] >> you should find Python's "text processing Nirvana" >> [...] > > I recommend, you write a "small" application I recommend you get a real name and do not post using the troll and spam- infested

Re: Threading in Python, Please check the script

2015-01-14 Thread Dave Angel
On 01/14/2015 07:11 AM, Robert Clove wrote: Can u provide me the pseudo script. You say you're a beginner. If so, you shouldn't be trying to use threads, which are tricky. I've been programming for 46 years, and I seldom have had to write multi-threading code. But this looks like a school

Re: Threading in Python, Please check the script

2015-01-14 Thread Robert Clove
Can u provide me the pseudo script. On Wed, Jan 14, 2015 at 4:10 PM, Dave Angel wrote: > On 01/14/2015 01:22 AM, Robert Clove wrote: > >> Hi All, >> >> > In any new thread, you should specify what versions of Python and OS > you're using. I'll assume Python 2.7 and Linux for this message. > >

Re: Performance in exec environnements

2015-01-14 Thread Chris Angelico
On Wed, Jan 14, 2015 at 8:02 PM, Jean-Baptiste Braun wrote: > What I'm trying to do is to map a transformation description in a markup > langage (XSLT) in python to improve execution time. Here is a simplification > of what it looks like : > > XSLT : > > > >Mr > > >Mrs > >

Re: What does "pip install" do?

2015-01-14 Thread Ben Finney
Fabien writes: > On 12.01.2015 23:46, Chris Angelico wrote: > > As far as I know, it's equivalent to three steps: > > > > 1) Download the appropriate version of a package (the latest, if you > > didn't say otherwise) > > 2) Extract that package > > 3) Run 'python setup.py'. > > > > What setup.py

Re: Using a ChangeLog as a canonical source of package metadata

2015-01-14 Thread Ben Finney
Ben Finney writes: > The idea is to parse from the Changelog the version metadata, and > record it in Setuptools metadata. Then the ‘pkg_resources’ module of > Setuptools allows programmatic access to that metadata. One tricky aspect is: at what specific point should the Changelog be parsed and

Re: Threading in Python, Please check the script

2015-01-14 Thread Dave Angel
On 01/14/2015 01:22 AM, Robert Clove wrote: Hi All, In any new thread, you should specify what versions of Python and OS you're using. I'll assume Python 2.7 and Linux for this message. I have made a script in which i have started two thread named thread 1 and thread 2. In thread 1 one fu

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\ua000' in position 0: ordinal not in range(128)

2015-01-14 Thread Dave Angel
On 01/13/2015 10:26 PM, Peng Yu wrote: Hi, First, you should always specify your Python version and OS version when asking questions here. Even if you've been asking questions, many of us cannot keep track of everyone's specifics, and need to refer to a standard place, the head of the cur

Re: List of "python -m" tools

2015-01-14 Thread Albert-Jan Roskam
- Original Message - > From: Irmen de Jong > To: python-list@python.org > Cc: > Sent: Wednesday, January 14, 2015 12:01 AM > Subject: Re: List of "python -m" tools > > On 12-1-2015 5:17, Miki Tebeka wrote: >> Greetings, >> >> I've compiled a list of "python -m" tools at > python

Re: Performance in exec environnements

2015-01-14 Thread Jean-Baptiste Braun
2015-01-13 22:48 GMT+01:00 Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info>: > So you have been comparing: > > 2 > > versus > > exec('1+1') > > > The first case just fetches a reference to a pre-existing int object, and > then deletes the reference. That's fast. > > The second case:

"cannot set color attribute.." with Mayavi

2015-01-14 Thread sperelat
Hello. I use mayavi module to plot some function on a spherical surface. The code read data from files and make 3d plot. This code worked well when I ran it with ipython interpreter on one machine. -code from numpy import * from mayavi.mlab im

Is anyone doing Python 3 bindings for the IUP GUI library?

2015-01-14 Thread Mark Summerfield
Just wondering if anyone is doing Python 3 bindings for the IUP GUI library? The library is pure C and GUI only (so not a giant framework), and uses native controls. It comes with Lua bindings and I believe there are third-party Ruby bindings. http://webserver2.tecgraf.puc-rio.br/iup/ -- https:/

Re: Comparisons and sorting of a numeric class....

2015-01-14 Thread Ian Kelly
On Tue, Jan 13, 2015 at 5:12 PM, Andrew Robinson wrote: > So -- even a cursory thought shows that the information could be encoded in > a very few lines even without an instance of a subclass: > > class CAllFalse(): > @classmethod > def __nonzero__(Kls): return False > > class CPartFalse()