python

Python cloud hosting other than Google App Engine?

What options exist for Python Cloud Hosting other than Google App Engine? I'm looking for solutions that let me write and publish code to servers that will scale up automatically to meet demand. I don't want to spend my time on IT tasks. So far, I've really only found this: https://www.picloud.com/ App Engine is great, but has some im...

Regular Expressions...

How would I extract the word 'wrestle' from the following: type=weaksubj len=1 word1=wrestle pos1=verb stemmed1=y priorpolarity=negative using a regular expression? Thanks ...

How to setup fts3 with python2.7 on windows ?

I built sqlite with fts3 enabled from source using mingw, and it works from the sqlite3 command line program. However fts3 doesn't work in python. Replacing the sqlite3.dll in python27\dlls with the newly built dll from sqlite doesn't work. I still get the error: sqlite3.OperationalError: no such module: fts3 ...

Display image as grayscale using matplotlib

I'm trying to display a grayscale image using matplotlib.pyplot.imshow(). My problem is that the grayscale image is displayed as a colormap. I need the grayscale because I want to draw on top of the image with color. I read in the image and convert to grayscale using PIL's Image.open().convert("L") image = Image.open(file).convert(...

paramiko combine stdout and stderr

I am trying to combine the output of stdout and stderr. My belief is that this can be done with the set_combine_stderr() of a Channel object. This is what I am doing: SSH = paramiko.SSHClient() #I connect and everything OK, then: chan = ssh.invoke_shell() chan.set_combine_stderr(True) chan.exec_command('python2.6 subir.py') resultado =...

Python & C#: Is IronPython absolutely necessary?

I'm primarily a C# programmer, but have been left with a project that leaves me with 2 options: Call out to a python script (saved as a .py file) and process the return value, OR... Rewrite the whole python script (involving 6 .py files in total) in C#. Naturally, Option 2 is a MAJOR waste of time if I can simply implement Option 1. ...

More pythonic way to write this?

I have this code here: import re def get_attr(str, attr): m = re.search(attr + r'=(\w+)', str) return None if not m else m.group(1) str = 'type=greeting hello=world' print get_attr(str, 'type') # greeting print get_attr(str, 'hello') # world print get_attr(str, 'attr') # None Which works, but I am not particularly f...

Getting started with python development?

Possible Duplicate: How to learn Python? I'm looking for some good resources (books, tutorials, sites, etc) for getting started with Python development. Note, not web-specific like this question, just python in general. ...

How can I programmatically find the list of codecs known to Python?

I know that I can do the following: >>> import encodings, pprint >>> pprint.pprint(sorted(encodings.aliases.aliases.values())) ['ascii', 'base64_codec', 'big5', 'big5hkscs', 'bz2_codec', 'cp037', 'cp1026', 'cp1140', 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', 'cp1256', 'cp1257', 'cp1258', 'cp424', 'cp43...

How can I better structure this code?

I have an lxml.objectify data structure I get from a RESTful web service. I need to change a setting if it exists and create it if it doesn't. Right now I have something along the lines of the following, but I feel like it's ugly. The structure I'm looking in has a list of subelements which all have the same structure, so I can't just lo...

How do the compression codecs work in Python?

I'm querying a database and archiving the results using Python, and I'm trying to compress the data as I write it to the log files. I'm having some problems with it, though. My code looks like this: log_file = codecs.open(archive_file, 'w', 'bz2') for id, f1, f2, f3 in cursor: log_file.write('%s %s %s %s\n' % (id, f1 or 'NULL', f2...

Running Python command-line utility from Java

Hello: I developed a command-line utility which needs to be called from a Java GUI application. The team in charge on the Java GUI would like to bind my command-line application to a button in the GUI; the Python application is such that at the time we have no time or interest in rewriting it in Java. I have no experience whatsoever in...

Instant messenger streaming with libVLC python wrapper

I'm trying to develop an instant messenger client that supports video streaming. I am working with the libVLC wrapper for Python. Most basic functions of an IM client are already there, my problem comes with the video streaming. I've been able to do basic tests like streaming a video and playing it in a tkinter form with my own code. But...

How do I store a list (or dict) of key terms from a regular expression? -Python

I am quite new at python and regex so please bear with me. I am trying to read in a file, match a particular name using a regex while ignoring the case, and store each time I find it. For example, if the file is composed of Bill bill biLl biLL, I need to store each variation in a dictionary or list. Current code: import re import sys im...

Python Constants

I have done searches on Google and here at Stackoverflow but can not find what I am looking for. I am relatively new to Python. I looking to create a "settings" module where various application specific constants will be stored. Here is how I am wanting to setup my code settings.py CONSTANT = 'value' script.py import settings def...

Multiple versions of django admin page for the same model

In my django admin section, I'd like to show different versions of the admin page depending on what kind of user is currently logged in. I can think of a couple ways this might work, but haven't figured out how to do any of them. Perhaps I could put logic into the admin.ModelAdmin to look at the current user and change the 'exclude' fi...

gtk: nicer way to make cellrenderercombo finish editing as soon as an entry is selected

I have a TreeView with a CellRendererCombo in it. Currently, I've connected the editing signal to a function which changes the underlying model and does some other actions based on the new value. However, this is annoying for the user. Dropping down the list and clicking on a new item does not seem to cause editing to "finish". Instead t...

Python structure always stuck at 0 no matter what value you assign to it?

I was writing a module to compact bits to be passed to C program, but keep getting errors. After some tests, I found out that the field a of class Blah is stuck at 0 no matter what. Does anyone know if this is a bug or if I'm doing something wrong here? Sorry, I forgot to mention I'm using python 3.1.2 from http://www.python.org/downloa...

Selenium and Python: remove \n from returned selenium.get_text()

When I call selenium.get_text("foo") on a certain element it returns back a different value depending on what browser I am working in due to the way each browser handles newlines. Example: An elements string is "hello[newline]how are you today?[newline]Very well, thank you." When selenium gets this back from IE it gets the string "hel...

Equivalent of 'ismember' from Matlab in Python?

Hi I am trying to perform a comparison between the rows of two matrices A and B with the same number of columns. In matlab the command "ismember(a, b, 'rows')" returns a vector containing 1 where the rows of A are also rows of B and 0 otherwise, and also returns the highest index in B for each element in A that is a member of B. [tf, ...