python

django error:connection to localhost;3312 failed ,i used django-sphinx.

Traceback (most recent call last): File "D:\Python25\Lib\site-packages\django\core\servers\basehttp.py", line 280, in run self.finish_response() File "D:\Python25\Lib\site-packages\django\core\servers\basehttp.py", line 319, in finish_response for data in self.result: File "D:\Python25\Lib\site-packages\django\http\__ini...

wx.TextCtrl and wx.Validator

hello friends, I need to validate the textboxes with wx.Textvalidator. Any please help me to do this? How can i use wx.FILTER_ALPHA with validators and if the user is giving a wrong input how can i give them a message? i need to validate all the inputs when clicking on the save button? can any one provide me a sample code for this? ...

Is there an API for Wireshark, to develop programs/plugins that interact with it/enhance it?

Googling didn't give me great results. Is there any sort of API for Wireshark that abstracts away from the main source code so we can develop programs that interact with it and deal with the data it provides? edit: I appreciate the suggestions for different ways to receive packets, but I want to implement packet injection into Wiresha...

In Django, my request.session is not carrying over...does anyone know why?

In one view, I set: request.session.set_expiry(999) request.session['test'] = '123' In another view, I do: print request.session['test'] and it cannot be found. (error) It's very simple, I just have 2 views. It seems that once I leave a view and come back to it...it's gone! Why? ...

encoding mp3 from a audio stream of PyTTS

Hello every body, I work on text-to-speech trasforming text, in audio mp3 files, using python 2.5. I use pyTSS as a python Text-To-Speech module, to transform text in audio .wav files (in pyTTS is not possible to encode in mp3 format directly). So after that, I code these wav files, in mp3 format, using lame command line encoder. Now,...

How do I turn a dictionary into a string?

params = {'fruit':'orange', 'color':'red', 'size':'5'} How can I turn that into a string: fruit=orange&color=red&size=5 ...

How to send a HTTP Header request rather than HTTP URL in Python.

I'm doing Oauth, and Linkedin needs me to send a "header" request instead of URL request (I have no idea what that means). This is what someone says on Google: If the library you are using isn't using HTTP headers for the authorization, you're not going to be able to access protected resources. Most OAuth libraries have an o...

matching multiple line in python regular expression

hi, I want to extract the data between <tr> tags from an html page. I used the following code.But i didn't get any result. The html between the <tr> tags is in multiple lines category =re.findall('<tr>(.*?)</tr>',data); Please suggest a fix for this problem. ...

PyQt debugging in main loop

Hello. Can I debug PyQt application when is main loop running ? Pdb, NetBeans, PyDev, all "freeze" when sys.exit(app.exec_()) is executed. I probably missing something obvious. Or what can be problem, please ? I apologize for my "creepy" english. Thanks. ...

pydoc fails under Windows and Python 2.6.4

When trying to use pydoc under Windows and python.org 2.6.4 I get the following error: C:\>pydoc sys 'import site' failed; use -v for traceback Traceback (most recent call last): File "C:\programs\Python26\Lib\pydoc.py", line 55, in ? import sys, imp, os, re, types, inspect, __builtin__, pkgutil File "C:\programs\Python26\Lib\os...

Calculating conditional probabilities from joint pmfs in numpy, too slow. Ideas? (python-numpy)

I have a conjunctive probability mass function array, with shape, for example (1,2,3,4,5,6) and I want to calculate the probability table, conditional to a value for some of the dimensions (export the cpts), for decision-making purposes. The code I came up with at the moment is the following (the input is the dictionary "vdict" of the f...

What is the most lightweight way to transmit data over the internet using Python?

I have two computers in geographically dispersed locations, both connected to the internet. On each computer I am running a Python program, and I would like to send and receive data from one to the other. I'd like to use the most simple approach possible, while remaining somewhat secure. I have considered the following solutions, but I'...

Python: defining new functions on the fly using "with"

I want to convert the following code: ... urls = [many urls] links = [] funcs = [] for url in urls: func = getFunc(url, links) funcs.append(func) ... def getFunc(url, links): def func(): page = open(url) link = searchForLink(page) links.append(link) return func into the much more convenient code: urls =...

which is more efficient for buffer manipulations: python strings or array()

I am building a routine that processes disk buffers for forensic purposes. Am I better off using python strings or the array() type? My first thought was to use strings, but I'm trying to void unicode problems, so perhaps array('c') is better? ...

Netbeans not allowing Python 2.6 as default platform (forcing Jython2.5)

I am trying to get Netbeans python to run with the default python platform set to Python 2.6.1 (my system python), so in Netbeans I do the following: Tools -> Python Platform Set Python 2.6.1 to 'default' However, it seems impossible to make this stick. Whenever I restart Netbeans it's back to Jython 2.5 again. Moreover, I can obvious...

Python: default/common way to read png images

I haven't found a standard way in Python to read images. Is there really none (because there are so many functions for so many custom stuff that I really wonder that there are no functions to read images)? Or what is it? (It should be available in the MacOSX standard installation and in most recent versions on Linux distributions.) If t...

How bad is it to override a method from a third-party module?

How bad is it to redefine a class method from another, third-party module, in Python? In fact, users can create NumPy matrices that contain numbers with uncertainty; ideally, I would like their code to run unmodified (compared to when the code manipulates float matrices); in particular, it would be great if the inverse of matrix m could...

Inheritance in Python C++ extension

I have c++ library that need communicate with Python plugged in modules. Communication supposes implementing by Python some callback c++ interface. I have read already about writing extensions, but no idea how to develop inheritance. So something about: C++: class Broadcast { void set(Listener *){... } class Listener { void n...

Need code to get all files in directory and past another local?

hello, i need code python to get all pic files in diretorie e paste another dir for ex. in "c:\capture" confirm exist pic files, if true get all and paste in c:\backup\paste.1 sleep 30 min and confirm new files in c:\capture if true get all and past in c:\backup\paste.2 sorry my bad english tks ...

How do I access my classes from the python console on MAC OSX?

I'm trying to access my classes via from project import * But from the python console something seems to be off with the paths. How do I set the correct paths to my project so I can import classes? My models are stored in: /Users/username/project/project/model from project import * And the error reads: ImportError: No module...