python

Silverlight databinding with IronPython and Datagrid

We've been successfully using clrtype with IronPython 2.6 and Silverlight for databinding, based on the example provided by Lukás(: http://gui-at.blogspot.com/2009/11/inotifypropertychanged-and-databinding.html We create the binding when we create the datagrid columns programatically. Because we are using IronPython some of the static...

translate by replacing words inside existing text

What are common approaches for translating certain words (or expressions) inside a given text, when the text must be reconstructed (with punctuations and everythin.) ? The translation comes from a lookup table, and covers words, collocations, and emoticons like L33t, CUL8R, :-), etc. Simple string search-and-replace is not enough since...

Is_prime function via regex in python (from perl)

I've read this article where the /^1?$|^(11+?)\1+$/ Perl regex is used to test if a number is prime or not. Process: s = '1' * your_number If s matchs the regex, then it's not prime. If it doesn't, it's prime. How would you translate that regex to Python's re module? ...

Python - Determine the type of an object?

Is there a simple way to determine if a variable is a list, dictionary, or something else? Basically I am getting an object back that may be either type and I need to be able to tell the difference. ...

Is there a way for me to get detailed formatted information on a Python class?

So, I know I can use dir() to get information about class members etc. What I'm looking for is a way to get a nicely formatted report on everything related to a class (the members, docstrings, inheritance hierarchy, etc.). I want to be able to run this on the command-line so I can explore code and debug better. ...

python get a filtered list of files in directory

Hi, I am trying to get a list of files in a directory using python, but I do not want a list of ALL the files. What I essentially want is the ability to do something like the following but using python and not executing ls. ls 145592*.jpg If there is no built-in method for this, I am currently thinking of writing a for loop to itera...

Which version of python opencv should I go for?

Having successfully installed opencv 2.0 with python bindings I'm starting to run into trouble and before I go any further I wondered if I should change to another option. As ezod on this post says: "As a caveat, as of the 2.0 release, the new Python bindings are incomplete: many functions I would consider rather important missing. Mean...

How can I create stacked line graph with matplotlib?

I would like to be able to produce a stacked line graph (similar to the method used here) with Python (preferably using matplotlib, but another library would be fine too). How can I do this? This similar to the stacked bar graph example on their website, except I'd like the top of bar to be connected with a line segment and the area un...

Python subprocess get child's output

Possible Duplicates: How to get output from subprocess.Popen() Retrieving the output of subprocess.call() Here is my question. I have an executable called device_console. The device_console provides a command line interface to a device. In device_console, four commands can be run: status, list, clear and exit. Each command p...

Error message in python-mysql cursor: 1054 unknown column "x" in 'field list'

Hi there everyone, This is my first post! I also just started programming, so please bear with me! I am trying to load a bunch of .csv files into a database, in order to later perform various reports on the data. I started off by creating a few tables in mysql with matching field names and data types to what will be loaded into the ta...

Instantiate a Python class from a name

So i have a set of classes and a string with one of the class names. How do I instantiate a class based on that string? class foo: def __init__(self, left, right): self.left = left self.right = right str = "foo" x = Init(str, A, B) I want x to be an instantiation of class foo. ...

Python vars() global name error

Hi there, I'm having a bit of trouble understanding what's going wrong with the following function: def ness(): pie='yum' vars()[pie]=4 print vars()[pie] print yum So When I run that I get this result: >>> ness() 4 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 5, in ness NameErro...

Interpreting WAV Data

Hi everyone, I'm trying to write a program to display PCM data. I've been very frustrated trying to find a library with the right level of abstraction, but I've found the python wave library and have been using that. However, I'm not sure how to interpret the data. The wave.getparams function returns (2 channels, 2 bytes, 44100 Hz, 963...

PyObjC + Xcode 3.2 + Non-Apple Python

I want to get started trying to develop a few simple applications with PyObjC. I installed PyObjC and the Xcode templates. I know that PyObjC itself works, since I've run this script successfully. When I tried to create a project from the Cocoa-Python Application template and ran it, I got this error: Traceback (most recent call last): ...

Does anyone know of a Urwid like environment that is cross-platform for Python 3.x?

I would like it to run on Linux, OS X, and Windows (XP/Vista/7). Thanks for any input. ...

formatting currencies with Python

I would like to format integers as professional looking currency strings. For example: 1200000 -> $1.2 million 456 -> $456.00 Do you know a good library for this, ideally with localization to handle European formats. ...

python mechanize proxy question

I've got mechanize setup and working with python. I am adding support for using a proxy, but how do I check that I am actually using the proxy? Here is some code I am using: ip = 'some proxy ip address' br.set_proxies({"http://": ip} ) I started to wonder if it was working because just to do some testing I typed in: ip = 'asdfasd...

Get types of arguments in python

I'm learning python. I like to use help() or interinspect.getargspec to get information of functions in shell. But is there anyway I can get the argument/return type of function. ...

Are Python built-in container thread-safe ?

Hi, I would like to know if the python built-in container (list, vector, set...) are thread-safe ? Or do I need to implement a locking/unlocking environment for my shared variable. Thanks in advance ...

how does create a new app in pinax ???

thanks only need 'python manage.py startapp xx' ??? ...