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

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: 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
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: 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: 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: 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

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: 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

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: 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: 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 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 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 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: 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: 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: 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: 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: 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: 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.

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: 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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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: 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

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: 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

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 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: 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: 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: 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: 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: 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 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

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 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. > > >>>

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

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: 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

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: 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: 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: 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
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: 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: 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: 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: 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: 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: 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: 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

<    1   2