python

Network - testing connectivity [Python or C]

Let's say I want to see if my ftp server is online, how could I do this in a program. Also, what do you think would be the easiest least intrusive way. ...

Does NLTK have a tool for dependency parsing?

Hey all, I'm building a NLP application and have been using the Stanford Parser for most of my parsing work, but I would like to start using Python. So far, NLTK seems like the best bet, but I cannot figure out how to parse grammatical dependencies. I.e. this is an example from the Stanford Parser. I want to be able to produce this i...

Google App Engine: upload_data fails because "target machine actively refused it" on devserver

I'm trying to upload data from a CSV to my app using the devserver: appcfg.py upload_data --config_file="DataLoader.py" --filename="data.csv" --kind=Foo --url=http://localhost:8083/remote_api "path/to/app" The result: Application: appname; version: 1. Uploading data records. [INFO ] Logging to bulkloader-log-20100626.181045 [INFO ...

Refreshing label in Python

I creating applet in gnome panel. All code is good. But info in panel is static. But need refresh this info in time. 1 secon or 5 second... Here is part of python code: #!/usr/bin/env python # -*- coding: utf-8 -*- import sys import gobject import gtk import pygtk import gnomeapplet import time import urllib2 pygtk.require('2.0') def ...

What should I use for the backend of a 'social' website?

My two main requirements for the site are related to degrees of separation and graph matching (given two graphs, return some kind of similarity score). My first thought was to use MySql to do it, which would probably work out okay for storing how I want to manage 'friends' (similar to Twitter), but I'm thinking if I want to show users r...

py2exe com dll problem

hi; i'm trying making a com dll in python. but i try register to compiled dll have a error message "run time error r6034" and "could not load python dll" what is the solution this problem ? mycode : setup.py: # This is the distutils script for creating a Python-based com dll # server using ctypes.com. This script should be run like...

TypeError: unsupported operand type(s)

This is a program I'm writing that's supposed to display some text in a window... import pyglet from pyglet import window from pyglet.text.layout import TextLayout class Window(pyglet.window.Window): def __init__(self): super(Window, self).__init__(width = 800, height = 600, caption = "Proto...

import media does not work in Python

Hi all I am reading a book about python. There is a sample. The first line is: import media I am trying to do the same, but the error like below Traceback (most recent call last): File "<pyshell#6>", line 1, in <module> import media ImportError: No module named media I want to know, is the media a default library? Best Rega...

Growl Python binding with Click feedback?

Hi, I'm trying to use Growl Python binding to write a small application. One of the feature that's currently missing is the click notification sent to Python. I know in Objective-C, when a user click the notification, it will send the trigger to the running application. I'd like to do the similar thing in Python binding. When a user c...

Why can't I in python call HDIO_GETGEO?

#!/usr/bin/env python # -*- coding: utf-8 -*- ########## THIS NOW WORKS! ########## UNSUITABLE_ENVIRONMENT_ERROR = \ "This program requires at least Python 2.6 and Linux" import sys import struct import os from array import array # +++ Check environment try: import platform # Introduced in Python 2.3 except ImportError: ...

Getting size of Gtk.Table in python

Hello, I am having a problem with widget Gtk.Table - I would like to know, if there is a way how to get a current size of the table (number of rows and columns). Thank you, very much for help, Tomas ...

Python "denormalize" unicode combining characters

I'm looking to standardize some unicode text in python. I'm wondering if there's an easy way to get the "denormalized" form of a combining unicode character in python? e.g. if I have the sequence u'o\xaf' (i.e. latin small letter o followed by combining macron), to get ō (latin small letter o with macron). It's easy to go the other way: ...

URLs and side effects (Django)

I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a u...

Instantiating named GTK widgets in Python

Hi, I have a simple GUI build with Glade 3 and I have a gtk.Entry widget with name "input_entry1". I would like to instantiate new gtk.Entry widget called "input_entry2" but I would like to do it simply in Python code, not with Glade, but I can't figure out how to set a name to instance of widget (or create a named widget). Thanks a lot...

python-inverse-of-a-matrix failure to import

I thought that the code in the python-inverse-of-a-matrix was extremely interesting, particularly since I have used numpy for several years in computations that involve matrices. I was disappointed as the 2 imports from numpy failed. Here are the imports: from numpy import matrix from numpy import linalg Neither matrix nor linalg wer...

Including Bash autocompletion with setuptools

I've got a couple packages in PyPI, and I'd like to include autocompletion features with both of them. How would you check that Bash autocompletion should be installed at all (check for /etc/bash_completion, maybe?), and how would you install it with setup.py (preferably using setuptools)? ...

How to represent matrices in python

How can I represent matrices in python? ...

Sending binary data over IPC from C to Python

Hi All I have a C program and a Python program on the same machine. The C program generates some data in nested structures. What form of IPC is the best way to get this data across to the python program? Serializing in C (especially nested structures) is a real bear, from what I hear, due to lack of serialization libraries. I am not...

concat multiple block in jinja2 ?

I use jinja2 for my template engine in python. i would like to join content of multiple block and would like to render it at the end of the template, just before tag. { they are various JavaScript snippets throughout the code in multiple template which i would like to move to the end of the file, how do i do it ? } edit : I would l...

Is there any linux distribution that comes with python 3?

I would like to know if there is any Linux distribution where you can easily install and use Python 3. This means a distribution that will provide not only Python 3 binaries and updates but also python modules. I know that probably we are not going to see any python 3 as the default python interpretor so soon but at least I would like t...