Hi All:
I'm using python2.5 with scipy.weave to embed c code.
In my c code, there is no malloc() function, but I received error like
"glibc detected *** python: malloc(): memory corruption"
from time to time.(It's a random algorithm)
So how shall I debug it out?
Thanks
...
Hi
I need a tool, which can download some part of data from web server, and after that i want connection not be closed. Therfore, i thought about a script in python, which can do:
1) send request
2) read some part of response
3) will freeze - server should think that connection exist, and should not close it
is it possilbe to do it in ...
I am learn python now, and today, i met a problem
in
http://docs.python.org/release/2.5.4/tut/node8.html
6.1.1 Executing modules as scripts
When you run a Python module with
python fibo.py <arguments>
the code in the module will be executed, just as if you imported it, but with the
name set to "main". That means th...
Hi Guys!
I know that twisted will not "wait"... I am working with an XMPP client to exchange data with an external process. I send an request and need to fetch the corresponding answer. I use a sendMessage to send my request to the server. When the server answers a onMessage method will receive it and check if it an answer to a request ...
[edit]
Initially I thought this was a pyserial problem but it's not. Basically it's a system problem: Sending anything over the serial port (/dev/ttyS0) would need a "\n" or "\r" or else it'll just be buffered. Below is the original question. Is it a limitation of Linux driver or is there some settings I can change?
Hello there,
I'm tr...
I have some code that pulls data from a com-port and I want to make sure that what I got really is a printable string (i.e. ASCII, maybe UTF-8) before printing it. Is there a function for doing this? The first half dozon places I looked didn't have anything that looks like what I want. (string has printable but I didn't see anything (the...
Currently when I enter invalid options or omit positional arguments, argparse kicks me back to the prompt and displays the usage for my app. This is ok, but I would rather automatically display the full help listing (that explains the options, etc) than require the user to type
./myscript.py -h
Thanks!
Jamie
...
Hi,
I would like to use python for things I've been doing using bash. Is it possible to use the -c switch for long programs, e.g. a for loop with two statements? This would let me use python directly from command line, just like bash or php.
Thanks.
EDIT: Don't know how I missed it, simply doing a python -c ' and then pressing enter do...
The following code writes a simple sine at frequency 400Hz to a mono WAV file. How should this code be changed in order to produce a stereo WAV file. The second channel should be in a different frequency.
import math
import wave
import struct
freq = 440.0
data_size = 40000
fname = "WaveTest.wav"
frate = 11025.0 # framerate as a float
...
This is hopefully an easy question.
I'm having some trouble understanding the documentation for the new multiple database feature in Django 1.2. Primarily, I cant seem to find an example of how you actually USE the second database in one of your models.
When I define a new class in my models.py how do I specify which database I intend ...
Imagine a web application that allows a logged in user to run a shell command on the web server at the press of a button. This is relatively simple in most languages via some standard library os tools.
But if that command is long running you don't want your UI to hang. Again this is relatively easy to deal with using some sort of backgr...
The Code below gives me "none", How Can I fix? Using python 2.6
import urllib
URL = "http://download.finance.yahoo.com/d/quotes.csv?s=%s&f=sl1t1v&e=.csv"
symbols = ('GGP', 'JPM', 'AIG', 'AMZN','GGP', 'JPM', 'AIG', 'AMZN')
#symbols = ('GGP')
def fetch_quote(symbols):
url = URL % '+'.join(symbols)
fp = urllib.urlopen(url...
What is the best way to trap errors/exceptions with the CRM 4 Web service. Is there a way to get more detailed error messages from the web service? There is a custom application that creates orders and when the get a error message from the web service it is not very details or useful. Is there a better way to get more detailed message...
What are the differences between shell languages like bash, zsh, fish and the scripting languages above that makes them more suitable for the shell?
When using the command line the shell languages seem to be much easier. It feels for me much smoother to use bash for example than to use the shell profile in ipython, despite reports to th...
Hi,
I'm using Python to parse an auction site.
If I use browser to open this site, it will go to a loading page, then jump to the search result page automatically.
If I use urllib2 to open the webpage, the read() method only return the loading page.
Is there any python package could wait until all contents are loaded then read() meth...
I'm writing a Python generator which looks like "cat". My specific use case is for a "grep like" operation. I want it to be able to break out of the generator if a condition is met:
summary={}
for fn in cat("filelist.dat"):
for line in cat(fn):
if line.startswith("FOO"):
summary[fn] = line
break
S...
Dear Python Experts,
I have the following sample code where I download a pdf from the European Parliament website on a given legislative proposal:
EDIT: I ended up just getting the link and feeding it to adobes online conversion tool (see the code below):
import mechanize
import urllib2
import re
from BeautifulSoup import *
adobe = "...
I have code that, simplified down, looks like this:
run = functools.partial(run, grep=options.grep, print_only=options.print_only, force=options.force)
if not options.single and not options.print_only and options.n > 0:
pool = multiprocessing.Pool(options.n)
Map = pool.map
else: Map = map
for f in args:
with open(f) as fh:...
The "idata" I pulled from this URL needs to be turned into a sequence, how do i turn it into a sequence
import urllib, csv
URL = "http://download.finance.yahoo.com/d/quotes.csv?s=%s&f=sl1vt1&e=.csv"
symbols = ('GGP', 'JPM', 'AIG', 'AMZN','GGP', 'JPM', 'AIG', 'AMZN')
#symbols = ('GGP',)
def fetch_quote(symbols):
url = URL %...
I'm using pylons with sqlalchemy. I have several models, and found myself wrote such code again and again:
question = Session.query(Question).filter_by(id=question_id).one()
answer = Session.query(Answer).fileter_by(id=answer_id).one()
...
user = Session.query(User).filter_by(id=user_id).one()
Since the models are all extend class Bas...