python

Implement a server that receives and processes client request(cassandra as backend), Python or C++?

I am planning to build an inverted index searching system with cassandra as its storage backend. But I need some guidances to build a highly efficient searching daemon server. I know a web server written in Python called tornado, my questions are: Is Python a good choice for developing such kind of apps? Is Nginx(or Sphinx) a good exam...

How to check a list contained by another list without a loop?

As the title mentions,is there any builtins to do this job?I looked for that in dir(list) but got no usable one.Thanks. ...

Python subprocess: 64 bit windows server PIPE doesn't exist :(

I have a GUI that launches selected python scripts and runs it in cmd next to the gui window. I am able to get my launcher to work on my (windows xp 32 bit) laptop but when I upload it to the server(64bit windows iss7) I am running into some issues. The script runs, to my knowledge but spits back no information into the cmd window. My...

running jython bytecode using java

It looks like I'm missing something. When using Jython to run my Python code in Java, Java bytecode files are generated (test.py -> [email protected]). Can I run these classes directly using java? In other words, I want to make this: $ java test@py [additional cp args] work. The intent: writing Python code and not having to give away ...

python unichr problem

I've got some problem with unichr() on my server. Please see below: On my server (Ubuntu 9.04): >>> print unichr(255) Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'ascii' codec can't encode character u'\xff' in position 0: ordinal not in range(128) On my desktop (Ubuntu 9.10): >>> prin...

How to draw text in a bitmap using wxpython?

Hello, I want to draw a number centered inside a wx.EmptyBitmap. How can I do it using wxpython? Thanks in advance :) import wx app = None class Size(wx.Frame): def __init__(self, parent, id, title): frame = wx.Frame.__init__(self, parent, id, title, size=(250, 200)) bmp = wx.EmptyBitmap(100, 100) dc = w...

How to use thread in Django

I want to check users' subscribed dates for certain period. And send mail to users whose subscription is finishing (ex. reminds two days). I think the best way is using thread and timer to check dates. But I have no idea how to call this function. I don't want to make a separate program or shell. I want to combine this procedure to my dj...

Dynamically create class attributes

Hi, I need to dynamically create class attributes from a DEFAULTS dictionary. defaults = { 'default_value1':True, 'default_value2':True, 'default_value3':True, } class Settings(object): default_value1 = some_complex_init_function(defaults[default_value1], ...) default_value2 = some_complex_init_function(defaults[de...

Does wx.DC line has events?

A line created using the DrawLine method of wx.DC has the onClick and onMouseOver events? ...

Formwizards for editing in Django

Hi, I am in the process of making a webapp, and this webapp needs to have a form wizard. The wizard consists of 3 ModelForms, and it works flawlessly. But I need the second form to be a "edit form". That is, i need it to be a form that is passed an instance. How can you do this with a form wizard? How do you pass in an instance of a mo...

Get Django form field from model field

I'd like to create a form that includes fields from two separate models, along with some other regular (non-model) fields. The form will create an instance of each model. I don't think I can use inline formsets for this, since I don't want to include all the fields from both models. I'd like to create the form field without hard-coding ...

undefined symbol: PyUnicodeUCS2_Decode whilst trying to install psycopg2

I'm getting an error whilst trying to install psycopg2 on ubuntu 9.10 64 bit. The error is: >>> import psycopg2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "psycopg2/__init__.py", line 69, in <module> from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID ImportError: psycopg2/_psycopg.so: ...

Python Windows File Copy with Wildcard Support

I've been doing this all the time: result = subprocess.call(['copy', '123*.xml', 'out_folder\\.', '/y']) if result == 0: do_something() else: do_something_else() Until today I started to look into pywin32 modules, then I saw functions like win32file.CopyFiles(), but then I found it may not support copying files to a directo...

Search jpeg files using python

Hi, My requirement is to search for jpeg images files in a directory using python script and list the file names. Can anyone help me on how to identify jpeg images files. Thanks in advance... ...

Building a python module and linking it against a MacOSX framework

I'm trying to build a Python extension on MacOSX 10.6 and to link it against several frameworks (i386 only). I made a setup.py file, using distutils and the Extension object. I order to link against my frameworks, my LDFLAGS env var should look like : LDFLAGS = -lc -arch i386 -framework fwk1 -framework fwk2 As I did not find any 'fra...

Handling import errors when using doctest.

Hi there, every now and then when I code in Python, I have to do without certain third-party modules. Eg. when I'm writing user authentication, it can be done in several ways and one of them is by using LDAP. However if the user does not want to use LDAP auth., he can choose a different option in a config file and in that case he shou...

strip tags python

i want the following functionality. input : this is test <b> bold text </b> normal text expected output: this is test normal text i.e. remove the content of the specified tag ...

Emacs bulk indent for Python

Working with Python in Emacs if I want to add a try/except to a block of code, I often find that I am having to indent the whole block, line by line. In Emacs, how do you indent the whole block at once. I am not an experienced Emacs user, but just find it is the best tool for working through ssh. I am using Emacs on the command line(U...

Sending custom PyQt signals?

I'm practicing PyQt and (Q)threads by making a simple Twitter client. I have two Qthreads. Main/GUI thread. Twitter fetch thread - fetches data from Twitter every X minutes. So, every X minutes my Twitter thread downloads a new set of status updates (a Python list). I want to hand this list over to the Main/GUI thread, so that it can...

How can I monitor mouse events with Python Xlib instead of capture them?

I need to monitor and filter mouse events with Xlib in Python. So far I have found out that this code receives events, but does not pass them on, so I can't actually do anything with the mouse anymore. from Xlib.display import Display from Xlib import X display = Display(':0') root = display.screen().root root.grab_pointer(True, X.Bu...