python

python: Chess moves validation

Hi, Does anybody know if there is a free python chess moves validation function available somewhere? What I need. I have a diagram stored as a string, and move candidate. What I need is to see if move candidate is valid for the diagram. Would be really interested to see examples, if possible. The string looks this way: ememem...

Send HTML e-mail in App Engine / Python?

Can you please give me a simple, and straightforward python example of sending an HTML e-mail using App Engine? Plaintext is straightforward, but I'm having difficulties with HTML tags. ...

Integrating Jython Cpython

I am about to begin a project where I will likely use PyQt or Pyside. I will need to interface with a buggy 3rd party piece of server software that provides C++ and Java APIs. The Java APIs are a lot easier to use because you get Exceptions where with the C++ libraries you get segfaults. Also, the Python bindings to the Java APIs are ...

Google Wave Robot / Python Variable question

I'm experimenting/having a little fun with wave robot python apiv2. I made a little 8ball app for the robot which works fine, and now I'm trying to make a trivia app. I've never programmed in Python but I'm pretty sure my syntax is correct. Here is the relevant code: elif (bliptxt == "\n!strivia"): reply = blip.reply() if (triviaS...

Need help/guidance about creating a desktop application with gui

I'm planning to do an Desktop application using Python, to learn some Desktop concepts. I'm going to use GTK or Qt, I still haven't decided which one. Fact is: I would like to create an application with the possibility to be called from command line, AND using a GUI. So it would be useful for cmd fans, and GUI users as well. It would b...

Difficulties with Django on Google App Engine

I have a Django 1.1.1 project that works fine. I'm trying to import it to Google App Engine. I'm trying to follow these instructions. I run it on the dev server, and I get an import error: ImportError at / No module named mysite.urls This is the folder structure of mysite/: app.yaml <DIR> myapp index.yaml main.py manage.py...

How do I use udev to find info about inserted video media (e.g. DVDs)

I'm trying to port an application from using HAL to using pure udev. It is written in python and will use the gudev library, though I would love to see examples in any language. I'm able to get all attached video devices (such as cameras) via: import gudev client = gudev.Client(["video4linux"]) for device in client.get_devices(): p...

emacs: Inferior-mode python-shell appears "lagged"

Hi all - I'm a Python(3.1.2)/emacs(23.2) newbie teaching myself tkinter using the pythonware tutorial found here. Relevant code is pasted below the question. Question: when I click the Hello button (which should call the say_hi function) why does the inferior python shell (i.e. the one I kicked off with C-c C-c) wait to execute the say...

pip: upgrade package without upgrading dependencies

I'm using pip and virtualenv for my python application. I would like to upgrade to a new version of the application without touching the dependencies. When I use pip install -U, it tries to upgrade all the packages, and even uninstalls and re-installs the same version of a dependency package when there isn't a new version available. I al...

python to javascript

Please can anyone translate this python code into javascript. # def strip_punctuation(s): # for c in ',.":;!%$': # while s.find(c) is not -1: # s.replace(c, '') ...

template files evaluation in python

I am trying to use python for translating a set of templates to a set of configuration files based on values taken from a main configuration file. However, I am having certain issues. Consider the following example of a template file. file1.cfg.template %(CLIENT1)s %(HOST1)s %(PORT1)d C %(COMPID1)s %(CLIENT2)s %(HOST2)s %(PORT2)d ...

How to determine subprocess.Popen() failed when shell=True

Windows version of Python 2.6.4: Is there any way to determine if subprocess.Popen() fails when using shell=True? Popen() successfully fails when shell=False >>> import subprocess >>> p = subprocess.Popen( 'Nonsense.application', shell=False ) Traceback (most recent call last): File ">>> pyshell#258", line 1, in <module> p = subp...

How do I get an overview and a methodology for programming in Python

I've started to learn Python and programming from scratch. I have not programmed before so it's a new experience. I do seem to grasp most of the concepts, from variables to definitions and modules. I still need to learn a lot more about what the different libraries and modules do and also I lack knowledge on OOP and classes in Python. I...

Converting datetime.ctime() values to Unicode

I would like to convert datetime.ctime() values to Unicode. Using Python 2.6.4 running under Windows I can set my locale to Spanish like below: >>> import locale >>> locale.setlocale(locale.LC_ALL, 'esp' ) Then I can pass %a, %A, %b, and %B to ctime() to get day and month names and abbreviations. >>> import datetime >>> dateValue ...

How do I subtract two dates in Django/Python?

Hi! I'm working on a little fitness tracker in order to teach myself Django. I want to graph my weight over time, so I've decided to use the Python Google Charts Wrapper. Google charts require that you convert your date into a x coordinate. To do this I want to take the number of days in my dataset by subtracting the first weigh-in from...

Queue remote calls to a Python Twisted perspective broker?

The strength of Twisted (for python) is its asynchronous framework (I think). I've written an image processing server that takes requests via Perspective Broker. It works great as long as I feed it less than a couple hundred images at a time. However, sometimes it gets spiked with hundreds of images at virtually the same time. Because it...

building a pairwise matrix in scipy/numpy in Python from dictionaries

I have a dictionary whose keys are strings and values are numpy arrays, e.g.: data = {'a': array([1,2,3]), 'b': array([4,5,6]), 'c': array([7,8,9])} I want to compute a statistic between all pairs of values in 'data' and build an n by x matrix that stores the result. Assume that I know the order of the keys, i.e. I have a list of "la...

How do I get the Math equation of Python Algorithm?

ok so I am feeling a little stupid for not knowing this, but a coworker asked so I am asking here: I have written a python algorithm that solves his problem. given x > 0 add all numbers together from 1 to x. def intsum(x): if x > 0: return x + intsum(x - 1) else: return 0 intsum(10) 55 first what is this type of equation ...

Viewing Python's shelve objects in PHP

I am using Python for indexing utilizing the shelve functionality and I was wondering whether it was possible to open and read the files in PHP. I checked out the PHP Shelve option and it doesn't seem to be working on PHP 5.X I am getting (when running the example they gave me) PHP Fatal error: Cannot pass parameter 2 by reference i...

Lighting Fast CMS, a Django based CMS. Any experiences?

I've just came across Lighting Fast CMS, which seems to be very promising Django based content management system. Documentation seem to be very good, even though it is still in beta stage. It also has very nice buildout based installation. Also the core Components of it seem to be nicely decoupled. Does anyone have any experiences wit...