Re: efficient running median

2009-10-13 Thread Hendrik van Rooyen
On Tuesday, 13 October 2009 17:22:55 Janto Dreijer wrote: > I'm looking for code that will calculate the running median of a > sequence, efficiently. (I'm trying to subtract the running median from > a signal to correct for gradual drift). > > My naive attempt (taking the median of a sliding window

Re: RabbitMQ vs ApacheQpid (AMQP)

2009-10-13 Thread Hendrik van Rooyen
On Tuesday, 13 October 2009 11:42:03 jacopo wrote: > > Background: > I have a main machine dispatching heavy calculations to different > machines, collecting the results, performing some calculation on the > merged results and starting all over again with fresher data. I > implemented a first solut

Re: Question regarding multiprocessing and error: Can't pickle : attribute lookup __builtin__.instancemethod failed

2009-10-13 Thread Tennessee
I have found a way around my problem. -Tennessee -- http://mail.python.org/mailman/listinfo/python-list

Re: python along or bash combined with python (for manipulating files)

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 23:13:24 -0300, Peng Yu escribió: Bash is easy to use on manipulating files and directories (like change name or create links, etc) and on calling external programs. For simple functions, bash along is enough. However, bash does not support the complex functions. Python has

Re: python along or bash combined with python (for manipulating files)

2009-10-13 Thread TerryP
On Oct 14, 2:13 am, Peng Yu wrote: > Bash is easy to use on manipulating files and directories (like change > name or create links, etc) and on calling external programs. For > simple functions, bash along is enough. However, bash does not support > the complex functions. Python has a richer libra

Re: XML-RPC(using SimpleXMLRPCServer) slow on the first call

2009-10-13 Thread Gabriel Genellina
En Mon, 12 Oct 2009 18:58:45 -0300, Mahi Haile escribió: Hello all,I have an xml-rpc server running on a machine in the same LAN as the client. Both the server and the client are in Python. When I have a series of xmlrepc calls from the client to the server, the first call usually takes mu

Re: threading module, call thread.interrupt_main()

2009-10-13 Thread Gabriel Genellina
En Thu, 08 Oct 2009 14:18:48 -0300, Gabriel Genellina escribió: En Thu, 08 Oct 2009 00:33:04 -0300, §äŽmŠÛ€vªº...@€ù€Ñ escribió: I try to call thread.interrupt_main() function in my child thread's run method which is inherit threading.Thread class. But it didn't work, do

Re: for loop: range() result has too many items

2009-10-13 Thread Matt Nordhoff
Matt Nordhoff wrote: > Andre Engels wrote: > [snip] > >> However, I think that the better Python way would be to use a generator: >> >> def infinite_numbergenerator(): >> n = 0 >> while True: >> yield n >> n += 1 >> >> for i in infinite_numbergenerator(): >> ... > >

Re: What is Islam?-1

2009-10-13 Thread Rami Chowdhury
On Oct 13, 2009, at 19:15 , Mensanator wrote: On Oct 13, 8:47�pm, Rami Chowdhury wrote: On Oct 13, 2009, at 17:51 , J wrote: On Tue, Oct 13, 2009 at 20:05, Aahz wrote: There's no point in trying to reason with a Muslim. That's not funny, and if you were being serious, that was � incred

Re: for loop: range() result has too many items

2009-10-13 Thread Matt Nordhoff
Andre Engels wrote: [snip] > However, I think that the better Python way would be to use a generator: > > def infinite_numbergenerator(): > n = 0 > while True: > yield n > n += 1 > > for i in infinite_numbergenerator(): > ... That's what itertools.count() is for.

Re: Profiling python on OSX?

2009-10-13 Thread James Matthews
You can use valgrind and attach it to python (in which you recompile python for it...) On Mon, Oct 12, 2009 at 9:51 PM, nitroamos wrote: > Hello -- > > I'm a python noob, so I'm trying to figure out how to get access to > the same data I'm used to from gprof, if possible. I was able to get > cPy

Re: python-apache configuration

2009-10-13 Thread James Matthews
You need to load mod_python and read the docs (or you can use CGI and make sure apache owns the file) On Tue, Oct 13, 2009 at 3:55 PM, Bhanu Mangipudi wrote: > Hi, >> >> I am new to python I have few questions regarding configuring apache with >> python. > > > I have a hello_world.py file in

Re: python along or bash combined with python (for manipulating files)

2009-10-13 Thread samwyse
On Oct 13, 9:13 pm, Peng Yu wrote: > Bash is easy to use on manipulating files and directories (like change > name or create links, etc) and on calling external programs. For > simple functions, bash along is enough. However, bash does not support > the complex functions. Python has a richer libra

Question regarding multiprocessing and error: Can't pickle : attribute lookup __builtin__.instancemethod failed

2009-10-13 Thread tleeuwenb...@gmail.com
Hi all, Thanks in advance for any suggestions. I'm getting the following: Exception in thread Thread-1: Traceback (most recent call last): File "/work/tjl/apps/lib/python2.6/threading.py", line 525, in __bootstrap_inner self.run() File "/work/tjl/apps/lib/python2.6/threading.py", line 477

Re: Writing to function arguments during execution

2009-10-13 Thread John O'Hagan
On Mon, 12 Oct 2009, Rhodri James wrote: > On Sun, 11 Oct 2009 14:18:25 +0100, John O'Hagan > > wrote: > > Now I can change the output of the "work" function while it's running via > > raw_input(). However it's very crude, not least because the terminal > > echo of > > the new options is interspe

Re: What is Islam?-1

2009-10-13 Thread Mensanator
On Oct 13, 8:47�pm, Rami Chowdhury wrote: > On Oct 13, 2009, at 17:51 , J wrote: > > > On Tue, Oct 13, 2009 at 20:05, Aahz wrote: > > There's no point in trying to reason with a Muslim. > > That's not funny, and if you were being serious, that was � > incredibly > rude. > > >>>

python along or bash combined with python (for manipulating files)

2009-10-13 Thread Peng Yu
Bash is easy to use on manipulating files and directories (like change name or create links, etc) and on calling external programs. For simple functions, bash along is enough. However, bash does not support the complex functions. Python has a richer library that could provide support for complex fu

Re: What is Islam?-1

2009-10-13 Thread Rami Chowdhury
On Oct 13, 2009, at 17:51 , J wrote: On Tue, Oct 13, 2009 at 20:05, Aahz wrote: There's no point in trying to reason with a Muslim. That's not funny, and if you were being serious, that was incredibly rude. Not as much as posting in comp.lang.python. What exactly are you claiming is r

Re: The rap against "while True:" loops

2009-10-13 Thread Mensanator
On Oct 13, 5:38�pm, "Rhodri James" wrote: > On Tue, 13 Oct 2009 22:59:04 +0100, Mensanator wrote: > > And I'm not saying John nor the OP should stop > > using what works for them. But there are certainly > > valid reasons for "don't use while True" to be > > on the "Best Practices" list. > > Unfo

Re: What is Islam?-1

2009-10-13 Thread J
On Tue, Oct 13, 2009 at 20:05, Aahz wrote: There's no point in trying to reason with a Muslim. >>> >>> That's not funny, and if you were being serious, that was incredibly >>> rude. >> >>Not as much as posting in comp.lang.python. > > What exactly are you claiming is rude? This entire thread

Re: efficient running median

2009-10-13 Thread Janto Dreijer
On Oct 13, 6:12 pm, Peter Otten <__pete...@web.de> wrote: > Janto Dreijer wrote: > > I'm looking for code that will calculate the running median of a > > sequence, efficiently. (I'm trying to subtract the running median from > > a signal to correct for gradual drift). > > > My naive attempt (taking

Re: When to derive from object?

2009-10-13 Thread greg
Terry Reedy wrote: Every function with default arguments can be called two or more ways. Every function that returns None can be written two or more ways. And in general, anything of any sort with any kind of default can be written in two ways. Somehow I doubt that the ZoP was intended to disc

Re: reifying indent and dedent into braces

2009-10-13 Thread greg
Rustom Mody wrote: Context: I am trying to generate some python code and its indentation=structure is giving me a headache! When I generate Python code (or anything else with an indented structure) I usually define myself a class with a method for writing out a line, and a pair of methods for

Re: What is the correct way to define __hash__?

2009-10-13 Thread greg
Chris Rebert wrote: On Mon, Oct 12, 2009 at 7:04 PM, Steven D'Aprano wrote: This can be simplified to: return cmp((self._a, self._b), (other._a, other._b)) Assuming you're not using Python 3.x that is. If you're using Python 3, you won't be writing a __cmp__ method in the first place. --

Re: The rap against "while True:" loops

2009-10-13 Thread greg
Steven D'Aprano wrote: The best I have seen is that loops should have a single entry point and a single exit point, to make it easier to reason about pre- and post-conditions. But frankly I'm not convinced that's true -- or at least, multiple exists shouldn't *necessarily* leader to difficulty

Re: What is Islam?-1

2009-10-13 Thread Aahz
In article <7c2aedb4-9341-4b02-98a5-9d4332c5e...@f10g2000vbl.googlegroups.com>, Mensanator wrote: >On Oct 13, 2:01=EF=BF=BDpm, a...@pythoncraft.com (Aahz) wrote: >> In article <39b1ba4d-be69-477d-8baa-e65465bea...@a7g2000yqo.googlegroups.= >com>, >> Mensanator =EF=BF=BD wrote: >>> >>>There's no p

NeatX?

2009-10-13 Thread skip
Has anyone looked at/installed NeatX? http://code.google.com/p/neatx/ It's an X protocol compressor mostly written in Python. I thought some here might have experimented with it. If you have tried it, I'd like to hear your experiences. -- Skip Montanaro - s...@pobox.com - http://www.smont

Re: efficient running median

2009-10-13 Thread Raymond Hettinger
On Oct 13, 11:57 am, sturlamolden wrote: > On 13 Okt, 18:33, Paul Rubin wrote: > > > The obvious way to compute a running median involves a tree structure > > so you can quickly insert and delete elements, and find the median. > > That would be asymtotically O(n log

Re: ask help for a proble with invalid syntax

2009-10-13 Thread John Machin
On Oct 14, 9:09 am, leo zhao wrote: > I  try to a run a python numpy programe, however the python can't run > this program. > my python version is 2.6.2 , numpy  version is 1.3.0, however, the > program can run in previous numpy version(1.2.0), who can help me to > solve the problem, I will deeply

Re: ask help for a proble with invalid syntax

2009-10-13 Thread Steven D'Aprano
On Tue, 13 Oct 2009 23:54:58 +0100, MRAB wrote: >> syntax error: >> There' an error in your program: invalid syntax. >> > There are also a number of spelling mistakes. Shame on you MRAB, you'll letting down the fine old Internet tradition that anytime you point out somebody else's spelling mist

Re: ask help for a proble with invalid syntax

2009-10-13 Thread MRAB
leo zhao wrote: I try to a run a python numpy programe, however the python can't run this program. my python version is 2.6.2 , numpy version is 1.3.0, however, the program can run in previous numpy version(1.2.0), who can help me to solve the problem, I will deeply appreciate! the program is b

Re: The rap against "while True:" loops

2009-10-13 Thread Paul Rubin
Steven D'Aprano writes: > But the consequence of that simplicity and speed is that they're not as > general as a for-loop. This was a design decision. But change the design > and you could have something like this: > > [expr for name in seq until cond] > > which breaks when cond becomes true.

Re: Re: for loop: range() result has too many items

2009-10-13 Thread Dave Angel
Andre Engels wrote: On Tue, Oct 13, 2009 at 11:55 PM, Andre Engels wrote: for i in range(sys.maxint): if i % 100 =0: print i Grmbl cut-and-paste error... I meant of course: for i in xrange(sys.maxint): if i % 100 =0: print i What version of Python gives a

Re: ask help for a proble with invalid syntax

2009-10-13 Thread Robert Kern
On 2009-10-13 17:09 PM, leo zhao wrote: I try to a run a python numpy programe, however the python can't run this program. my python version is 2.6.2 , numpy version is 1.3.0, however, the program can run in previous numpy version(1.2.0), who can help me to solve the problem, I will deeply appr

Re: The rap against "while True:" loops

2009-10-13 Thread Rhodri James
On Tue, 13 Oct 2009 22:59:04 +0100, Mensanator wrote: And I'm not saying John nor the OP should stop using what works for them. But there are certainly valid reasons for "don't use while True" to be on the "Best Practices" list. Unfortunately, some of them seem to be reasons from my point of

Re: MUD Game Programmming - Python Modules in C++

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 18:08:53 -0300, Christopher Lloyd escribió: #include #include #include "Python.h" int main() { std::cout << "Starting Python Demo Test" << std::endl; Py_Initialize();// initialize python std::string str; std::getline( std::cin, str );

Re: MUD Game Programmming - Python Modules in C++

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 18:08:53 -0300, Christopher Lloyd escribió: #include #include #include "Python.h" int main() { std::cout << "Starting Python Demo Test" << std::endl; Py_Initialize();// initialize python std::string str; std::getline( std::cin, str );

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 17:38:44 -0300, Buck escribió: The only way to get your packages on the PYTHONPATH currently is to: * install the packages to site-packages (I don't have access) * edit the PYTHONPATH all users' environment (again, no access) * create some boilerplate that edits s

Re: The rap against "while True:" loops

2009-10-13 Thread Steven D'Aprano
On Tue, 13 Oct 2009 14:59:04 -0700, Mensanator wrote: > And I'm not saying John nor the OP should stop using what works for > them. But there are certainly valid reasons for "don't use while True" > to be on the "Best Practices" list. "Valid"? Well, maybe. But none of them are convincing to me. T

Re: The rap against "while True:" loops

2009-10-13 Thread Paul Rubin
Mensanator writes: > And I'm not saying John nor the OP should stop using what works for > them. But there are certainly valid reasons for "don't use while > True" to be on the "Best Practices" list. > > After all, how many times hve you put 'break' in a loop > comprehension?

Re: efficient running median

2009-10-13 Thread Paul Rubin
Janto Dreijer writes: > Well, I don't have a lot of theoretical reasoning behind wanting to > use a median filter. I have some experience applying it to images with > very good results, so that was the first thing I tried. It felt right > at the time and the results looked good. If this is image

ask help for a proble with invalid syntax

2009-10-13 Thread leo zhao
I try to a run a python numpy programe, however the python can't run this program. my python version is 2.6.2 , numpy version is 1.3.0, however, the program can run in previous numpy version(1.2.0), who can help me to solve the problem, I will deeply appreciate! the program is below: import sy

Re: What is Islam?-1

2009-10-13 Thread Mensanator
On Oct 13, 2:01�pm, a...@pythoncraft.com (Aahz) wrote: > In article <39b1ba4d-be69-477d-8baa-e65465bea...@a7g2000yqo.googlegroups.com>, > > Mensanator � wrote: > > >There's no point in trying to reason with a Muslim. > > That's not funny, and if you were being serious, that was incredibly > rude.

Re: for loop: range() result has too many items

2009-10-13 Thread Rhodri James
On Tue, 13 Oct 2009 22:17:58 +0100, Peng Yu wrote: The following code does not run because range() does not accept a big number. Is there a way to make the code work. I'm wondering if there is a way to write a for-loop in python similar to that of C style. xrange() Have you read the document

Re: efficient running median

2009-10-13 Thread Steven D'Aprano
On Tue, 13 Oct 2009 12:59:47 -0700, Paul Rubin wrote: > sturlamolden writes: >> > The obvious way to compute a running median involves a tree structure >> > so you can quickly insert and delete elements, and find the median. >> > That would be asymtotically O(n log n) but messy to implement. >>

Re: The rap against "while True:" loops

2009-10-13 Thread Mensanator
On Oct 12, 4:59�pm, David C Ullrich wrote: > kj wrote: > > I'm coaching a group of biologists on basic Python scripting. �One > > of my charges mentioned that he had come across the advice never > > to use loops beginning with "while True". �Of course, that's one > > way to start an infinite loop,

Re: The rap against "while True:" loops

2009-10-13 Thread Mensanator
On Oct 13, 11:27�am, Ethan Furman wrote: > Mensanator wrote: > > On Oct 13, 3:44 am, John Reid wrote: > > >>while not done: > > >>seems very dangerous to me as you'd have to > > >>del done > > >>before writing the same construct again. That's the sort of thing that > >>leads to errors. > > >Duh.

Re: MUD Game Programmming - Python Modules in C++

2009-10-13 Thread Irmen de Jong
Christopher Lloyd wrote: Hello all, I'm new to Python and new to this list, although I've done some digging in the archives and already read up on the problem I'm about to describe. I'm a relatively inexperienced programmer, and have been learning some basic C++ and working through the demos

Re: for loop: range() result has too many items

2009-10-13 Thread Andre Engels
On Tue, Oct 13, 2009 at 11:55 PM, Andre Engels wrote: > for i in range(sys.maxint): >    if i % 100 == 0: >       print i Grmbl cut-and-paste error... I meant of course: for i in xrange(sys.maxint): if i % 100 == 0: print i -- André Engels, andreeng...@gmail.com -- http://mail.p

Re: for loop: range() result has too many items

2009-10-13 Thread Andre Engels
On Tue, Oct 13, 2009 at 11:17 PM, Peng Yu wrote: > Hi, > > The following code does not run because range() does not accept a big > number. Is there a way to make the code work. I'm wondering if there > is a way to write a for-loop in python similar to that of C style. > > for(int i = 0; i < a_big_

Re: for loop: range() result has too many items

2009-10-13 Thread Stephen Hansen
On Tue, Oct 13, 2009 at 2:17 PM, Peng Yu wrote: > Hi, > > The following code does not run because range() does not accept a big > number. Is there a way to make the code work. I'm wondering if there > is a way to write a for-loop in python similar to that of C style. > > for(int i = 0; i < a_big_

Re: for loop: range() result has too many items

2009-10-13 Thread Steven D'Aprano
On Tue, 13 Oct 2009 16:17:58 -0500, Peng Yu wrote: > Hi, > > The following code does not run because range() does not accept a big > number. Incorrect. >>> range(sys.maxint+2, sys.maxint+5) [2147483649L, 2147483650L, 2147483651L] > Is there a way to make the code work. I'm wondering if there

Re: for loop: range() result has too many items

2009-10-13 Thread Mel
Peng Yu wrote: > Hi, > > The following code does not run because range() does not accept a big > number. Is there a way to make the code work. I'm wondering if there > is a way to write a for-loop in python similar to that of C style. > > for(int i = 0; i < a_big_number; ++ i) > > Regards, > Pe

Re: efficient running median

2009-10-13 Thread Janto Dreijer
On Oct 13, 8:29 pm, Dale Dalrymple wrote: > On Oct 13, 8:22 am, Janto Dreijer wrote: > > > I'm looking for code that will calculate the running median of a > > sequence, efficiently. (I'm trying to subtract the running median from > > a signal to correct for gradual drift). > > ... > >  Any sugge

Re: efficient running median

2009-10-13 Thread Janto Dreijer
On Oct 13, 9:59 pm, Paul Rubin wrote: > sturlamolden writes: > > > The obvious way to compute a running median involves a tree structure > > > so you can quickly insert and delete elements, and find the median. > > > That would be asymtotically O(n log n) but messy t

for loop: range() result has too many items

2009-10-13 Thread Peng Yu
Hi, The following code does not run because range() does not accept a big number. Is there a way to make the code work. I'm wondering if there is a way to write a for-loop in python similar to that of C style. for(int i = 0; i < a_big_number; ++ i) Regards, Peng $ cat for_loop.py import sys de

Re: speed up linecache.getline()

2009-10-13 Thread Peter Otten
bbarb...@inescporto.pt wrote: > I am using linecache.getline, to access to a line in a long file. It s > really fast, appx 4seconds, but I was just wandering if any of you, > know either another way, or there is something that I can do to speed > it up... thank you very much for your help!! If i

Re: efficient running median

2009-10-13 Thread sturlamolden
On 13 Okt, 18:33, Paul Rubin wrote: > The obvious way to compute a running median involves a tree structure > so you can quickly insert and delete elements, and find the median. > That would be asymtotically O(n log n) but messy to implement. QuickSelect will find t

Re: efficient running median

2009-10-13 Thread Paul Rubin
Janto Dreijer writes: > I'm looking for code that will calculate the running median of a > sequence, efficiently. (I'm trying to subtract the running median from > a signal to correct for gradual drift). Is that a known and valid technique of correcting for drift? Maybe what you really want is a

Re: Form Value Won't Post/Submit

2009-10-13 Thread SuperMetroid
Anyway.. I'll close this thread, since Piet is helping me somewhere else. No more responses here are needed, thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Form Value Won't Post/Submit

2009-10-13 Thread SuperMetroid
Oops. Now I changed the URL, as you suggested, and I get the same error. -- http://mail.python.org/mailman/listinfo/python-list

Re: Form Value Won't Post/Submit

2009-10-13 Thread SuperMetroid
Thank you so much for the quick response. I tried exactly what you said but it still yields an error.. :/ Here is the Error Message: Traceback (most recent call last): File "C:\Python31\htmlparser.py", line 40, in form = urllib.request.OpenerDirector.open('http://www.imvu.com/ catalog/web_m

Re: Python XMLRPC question

2009-10-13 Thread Falcolas
On Oct 13, 2:22 pm, "Gabriel Genellina" wrote: > En Tue, 13 Oct 2009 16:55:09 -0300, Falcolas escribió: [snip] > > Looks like the simplest way to change that would be to inherit from > > the SimpleXMLRPCRequestHandler class and implement your own > > log_request method. You could then pass that t

MUD Game Programmming - Python Modules in C++

2009-10-13 Thread Christopher Lloyd
Hello all, I'm new to Python and new to this list, although I've done some digging in the archives and already read up on the problem I'm about to describe. I'm a relatively inexperienced programmer, and have been learning some basic C++ and working through the demos in Ron Penton's "MUD Game P

Re: setting variables in the local namespace

2009-10-13 Thread Carl Banks
On Oct 13, 12:23 pm, Mick Krippendorf wrote: > Carl Banks schrieb: > > > Lemme guess. > > > You tried this at the interactive prompt and concluded it worked in > > general, right? > > Yes. Thank you for enlighten me. > > > One of these days we're going to have a thread like this where no one > > m

Re: RabbitMQ vs ApacheQpid (AMQP)

2009-10-13 Thread Roger Binns
jacopo wrote: > I am considering two solutions for a distributed system: either > RabbitMQ with py-amqplib or ApacheQpid with its own set of API. Have you considered the multiprocessing module? http://docs.python.org/library/multiprocessing.html#using-a-remote-manager Roger -- http://mail.py

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Buck
On Oct 13, 9:37 am, Ethan Furman wrote: > Buck wrote: > >I'd like to get to zero-installation if possible. It's easy with > >simple python scripts, why not packages too? I know the technical > >reasons, but I haven't heard any practical reasons. > > I don't think we mean the same thing by "zero

Re: problem with running os.path.walk()

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 16:32:07 -0300, MalC0de escribió: where's the problem with the following code ? I couldn't see any result while running as a script : #!/usr/bin/python import time import os def walker2(arg,dirname,filenames): cutoff = time.time() - (arg * 24 * 60 * 60) f

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Stef Mientki
Stephen Hansen wrote: On Mon, Oct 12, 2009 at 4:15 PM, Stef Mientki > wrote: Hierarchical choices are done on todays knowledge, tomorrow we might have different views and want/need to arrange things in another way. An otter may become a reptile ;

Re: Python XMLRPC question

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 16:55:09 -0300, Falcolas escribió: On Oct 13, 12:47 pm, prasanna wrote: In using Python's XMLRPC, there is a statement that gets printed on stdout of the form:                  localhost - - [12/Oct/2009 23:36:12] "POST /RPC2 HTTP/ 1.0" 200 - Where does this message origi

Reply Delays

2009-10-13 Thread Ned Deily
In article <7f014ea60910130325n34156771r7f79eed588eaa...@mail.gmail.com>, Chris Colbert wrote: > Heh, for whatever reason, your post is dated earlier than my response, > but wasn't here when I sent mine. [...] It's not always obvious but this "forum" is multiplexed in several places. It's av

Re: efficient running median

2009-10-13 Thread Paul Rubin
sturlamolden writes: > > The obvious way to compute a running median involves a tree structure > > so you can quickly insert and delete elements, and find the median. > > That would be asymtotically O(n log n) but messy to implement. > > QuickSelect will find the median in O(log n) time. That ma

Re: Python XMLRPC question

2009-10-13 Thread Falcolas
On Oct 13, 12:47 pm, prasanna wrote: > In using Python's XMLRPC, there is a statement that gets printed on > stdout of the form: >                  localhost - - [12/Oct/2009 23:36:12] "POST /RPC2 HTTP/ > 1.0" 200 - > > Where does this message originate? Can I turn it off, or at least > redirect i

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Stef Mientki
[snip] The key is to put all the core functionality into a package, and place the package where Python can find it. Also, it's a good idea to use relative imports from inside the package. There is no need to juggle with sys.path nor even set PYTHONPATH nor import __main__ nor play any stra

python-apache configuration

2009-10-13 Thread Bhanu Mangipudi
> > Hi, > > I am new to python I have few questions regarding configuring apache with > python. I have a hello_world.py file in /var/www/html/testing/ with permissions 755, but when I try to access http://localhost/testing/helloworl.py in mu web browser. The web browser is showing the out put

problem with running os.path.walk()

2009-10-13 Thread MalC0de
heya there, where's the problem with the following code ? I couldn't see any result while running as a script : #!/usr/bin/python import time import os def walker2(arg,dirname,filenames): cutoff = time.time() - (arg * 24 * 60 * 60) for filename in filenames : stats

Re: setting variables in the local namespace

2009-10-13 Thread Mick Krippendorf
Carl Banks schrieb: > Lemme guess. > > You tried this at the interactive prompt and concluded it worked in > general, right? Yes. Thank you for enlighten me. > One of these days we're going to have a thread like this where no one > makes this mistake. Don't know when, but one day it will happen

Re: When to derive from object?

2009-10-13 Thread Terry Reedy
Paul Rudin wrote: Benjamin Kaplan writes: It's redundant. Python 3 cleaned up a lot of the warts that appeared in Python over the years. Old-style classes (classes that didn't inherit from object) were one of them. Every class in Python 3 is derived from object whether you specify it or not.

Re: efficient running median

2009-10-13 Thread Daniel Stutzbach
On Tue, Oct 13, 2009 at 10:22 AM, Janto Dreijer wrote: > I'm looking for code that will calculate the running median of a > sequence, efficiently. (I'm trying to subtract the running median from > a signal to correct for gradual drift). > In the past, I've used the following algorithm which appr

PyCon 2010 US - Call For Tutorials Ending Soon

2009-10-13 Thread Greg Lindstrom
The period to submit proposals to teach a tutorial at PyCon 2010 US ends on Sunday, October 18th. There is still time for you to get a proposal on your favorite Python topic and teach a 3-hour class (with breaks and refreshments) to your colleagues on the Wednesday or Thursday before the conferenc

Re: What is Islam?-1

2009-10-13 Thread Aahz
In article <39b1ba4d-be69-477d-8baa-e65465bea...@a7g2000yqo.googlegroups.com>, Mensanator wrote: > >There's no point in trying to reason with a Muslim. That's not funny, and if you were being serious, that was incredibly rude. -- Aahz (a...@pythoncraft.com) <*> http://www.pyth

Re: Nested Menus

2009-10-13 Thread Victor Subervi
This is probably more appropriate for the MySQL list, but since this is Dennis' pseudo-code... Dennis wrote the following: cursor.execute("""create table if not exists Relationship (ID integer auto_increment primary key, Parent integer not null, foreign key (Categories.ID), Chi

Re: setting variables in the local namespace

2009-10-13 Thread Peter Pearson
On Tue, 13 Oct 2009 17:05:03 +0100, Chris Withers wrote: [snip] > - what is so wrong with wanting to set a variable in the local namespace > based on a name stored in a variable? I'm not sure it's "so wrong" that one should never, ever do it, but it *does* blur the boundary between the program an

Python XMLRPC question

2009-10-13 Thread prasanna
In using Python's XMLRPC, there is a statement that gets printed on stdout of the form: localhost - - [12/Oct/2009 23:36:12] "POST /RPC2 HTTP/ 1.0" 200 - Where does this message originate? Can I turn it off, or at least redirect it into a logging file? I am planning to run the ser

Re: setting variables in the local namespace

2009-10-13 Thread Dave Angel
Mick Krippendorf wrote: Yes, and, uh, yes. "locals()['foo'] = bar" works in that it does the same thing as "foo = bar". So why don't you write that instead? Mick. I wouldn't expect it to do the same thing at all, and it doesn't, at least not in Python 2.6.2. It may store the "bar" som

Re: efficient running median

2009-10-13 Thread Dale Dalrymple
On Oct 13, 8:22 am, Janto Dreijer wrote: > I'm looking for code that will calculate the running median of a > sequence, efficiently. (I'm trying to subtract the running median from > a signal to correct for gradual drift). > ... > Any suggestions? For a reference try: Comparison of algorithms

Re: Load a list subset with pickle?

2009-10-13 Thread Robert Kern
On 2009-10-13 13:00 PM, Peng Yu wrote: I use pickle to dump a long list. But when I load it, I only want to load the first a few elements in the list. I am wondering if there is a easy way to do so? Thank you! Not by pickling the list. However, you can concatenate pickles, so you could just pi

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 13:28:05 -0300, Buck escribió: On Oct 12, 3:34 pm, "Gabriel Genellina" wrote: Quoting Steven D'Aprano   (changing names slightly): """You would benefit greatly from separating the interface from the backend. You should arrange matters so that the users see something like t

Re: When to derive from object?

2009-10-13 Thread Paul Rudin
Benjamin Kaplan writes: > > It's redundant. Python 3 cleaned up a lot of the warts that appeared > in Python over the years. Old-style classes (classes that didn't > inherit from object) were one of them. Every class in Python 3 is > derived from object whether you specify it or not. ... it coul

Load a list subset with pickle?

2009-10-13 Thread Peng Yu
I use pickle to dump a long list. But when I load it, I only want to load the first a few elements in the list. I am wondering if there is a easy way to do so? Thank you! -- http://mail.python.org/mailman/listinfo/python-list

Re: setting variables in the local namespace

2009-10-13 Thread Carl Banks
On Oct 13, 9:39 am, Mick Krippendorf wrote: > Yes, and, uh, yes. "locals()['foo'] = bar" works in that it does the > same thing as "foo = bar". So why don't you write that instead? Lemme guess. You tried this at the interactive prompt and concluded it worked in general, right? Even though when

Is pythonic version of scanf() or sscanf() planned?

2009-10-13 Thread ryniek90
In article , ryniek90 wrote: But I remember that lambda function also was unwelcome in Python, but finally it is and is doing well. So maybe someone, someday decide to put in Python an alternative, really great implementation of scanf() ? How long have you been using Python? lambd

Re: setting variables in the local namespace

2009-10-13 Thread Mel
Chris Withers wrote: > - what is so wrong with wanting to set a variable in the local namespace > based on a name stored in a variable? What's wrong is that no other statement using the local name space can know what that name might be. It's a documented fact that changing the locals() diction

Re: setting variables in the local namespace

2009-10-13 Thread Carl Banks
On Oct 13, 9:05 am, Chris Withers wrote: > Hi All, > > Say I have a piece of code like this: > >          mname = model.__name__ >          fname = mname+'_order' >          value = request.GET.get('order') >          if value: >              request.session[fname]=value >          else: >        

Re: When to derive from object?

2009-10-13 Thread Benjamin Kaplan
On Tue, Oct 13, 2009 at 1:34 PM, Anson Mackeracher wrote: > Can someone point me to some reason on why not to derive from Object > when using Python >= 3.0? I am a Python novice, I need some > background. > It's redundant. Python 3 cleaned up a lot of the warts that appeared in Python over the ye

Re: efficient running median

2009-10-13 Thread Ethan Furman
Janto Dreijer wrote: I'm looking for code that will calculate the running median of a sequence, efficiently. (I'm trying to subtract the running median from a signal to correct for gradual drift). My naive attempt (taking the median of a sliding window) is unfortunately too slow as my sliding wi

Re: When to derive from object?

2009-10-13 Thread Anson Mackeracher
Can someone point me to some reason on why not to derive from Object when using Python >= 3.0? I am a Python novice, I need some background. On Oct 13, 10:49 am, Bruno Desthuilliers wrote: > Igor Mikushkin a écrit : > > > Hello all! > > > I'm a newbie to Python. > > Welcome onboard > > > Could yo

Re: efficient running median

2009-10-13 Thread Dave Angel
Janto Dreijer wrote: I'm looking for code that will calculate the running median of a sequence, efficiently. (I'm trying to subtract the running median from a signal to correct for gradual drift). My naive attempt (taking the median of a sliding window) is unfortunately too slow as my sliding wi

Re: The rap against "while True:" loops

2009-10-13 Thread Ethan Furman
Mensanator wrote: On Oct 13, 3:44�am, John Reid wrote: while not done: seems very dangerous to me as you'd have to del done before writing the same construct again. That's the sort of thing that leads to errors. Duh. I won't write silly code like that either. If I need more than one loop

Re: setting variables in the local namespace

2009-10-13 Thread Duncan Booth
Chris Withers wrote: > Now, if I want to do *exactly* the same thing with a variable named > 'sort', I have to copy and paste the above code or do something hacky > like have a dict called "vars" and manipulate that, or factor the above > into a function and take the hit on the extra function

  1   2   >