python

How do I get PyFacebook working with the Google App Engine Patch?

I've tried to follow the advice of this question: http://stackoverflow.com/questions/984071/facebook-django-and-google-app-engine, however I've run into a number of problems. The first is that from facebook.djangofb import facebook doesn't work because when I try to use the decorator @facebook.require_login(), it complains that the face...

C++ code/files dump

hi I have gathered a collection of various templates, small utility classes, some obscure domain specific snippets of C++ and python written by me. was wondering if there is a public domain or open source code repository/dump where the code can be contributed.is there such a thing? I have source Forge projects, but this files are somew...

Python: Why can't I get my decorator to work?

This works now for those new to this question: class ensureparams(object): """ Used as a decorator with an iterable passed in, this will look for each item in the iterable given as a key in the params argument of the function being decorated. It was built for a series of PayPal methods that require different params,...

Implementing USZipCodeField and USStateField in django

I'm looking to implement a zipcode field in django using the form objects from localflavor, but not quite getting them to work. I want to have a zipcode field in a form (or ModelForm in my case), but the fields never validate as a zipcode when calling _get_errors() on the form object. The way I'm implementing it seems right to me but is...

Python "from xxx.yyy import xxx" error.

I'm working with the PyFacebook package in Python, and I've seen a number of times people mention that you can write an import statement as follows: from facebook.djangofb import facebook which will alias the "djangofb" module as "facebook." I'm trying to run this from the Python CLI, and it doesn't work because it thinks facebook.me...

Django not recognizing the MEDIA_URL path?

So I'm trying to get TinyMCE up and running on a simple view function, but the path to the tiny_mce.js file gets screwed up. The file is located at /Users/home/Django/tinyMCE/media/js/tiny_mce/tiny_mce.js. I believe that /media/js/tiny_mce/tiny_mce.js is correct, as the development server has no access to files above the root of the Djan...

Django One-To-Many Models

The following models describe a vulnerability and the URLs out on the internet that reference that vulnerability. Assume that each URL only ever talks about 1 vulnerability, and that many URLs will discuss that vulnerability. Is this the correct way to lay out the model? class Vuln(models.Model): pub_date = models.DateTimeField("Publi...

Sorting datetime objects while ignoring the year?

I have a list of birthdays stored in datetime objects. How would one go about sorting these in Python using only the month and day arguments? For example, [ datetime.datetime(1983, 1, 1, 0, 0) datetime.datetime(1996, 1, 13, 0 ,0) datetime.datetime(1976, 2, 6, 0, 0) ... ] Thanks! :) ...

Using object id as a hash for objects in Python

Is it wise to use the object id as a hash key (via. the __hash__) to be able to hash an otherwise mutable object for a single instance of a program? Using the object attributes would be nicer but they're all mutable and can change. This occurred to me while looking at http://stackoverflow.com/questions/2038010/sets-of-instances/2038019...

Python Jpype integration

Hi i am using JPype The following is the code i am trying to use from jpype import * startJVM("C:\Program Files\Java\jdk1.6.0_14\jre\bin\client\jvm.dll","-ea") java.lang.System.out.println("hai") shutdownJVM() It is giving error in the execution of the println statement java.lang.System.out.println("hai") ...

Opensource Online IDE

There're several online IDEs for PHP and some even for Python, but is there any open-source online IDE like IDEone that supports atleast the major languages (PHP, Python, Ruby etc..)? ...

Index of item in list when only part of the item is known

This is a follow-up on a previous question of mine regarding searching in lists of lists I have a list with pairs of values as lists in it. [['a',5], ['b',3], ['c',2] ] I know the first element of each pair but I don't know the second (it's the result of a calculation and stored in the list with the first element. I sorted the li...

Python library needed

I am trying to run a python script which has the following statements: import random as RD import pylab as PL import scipy as SP import networkx as NX Where can I download these packages? I have installed these packages and I get the following error when I run my code I am getting the following error when I run the code Traceback (...

Sets module deprecated warning

When I run my python script I get the following warning DeprecationWarning: the sets module is deprecated How do I fix this? ...

Is there a better library than urlgrabber for fetching remote urls in python?

I'm writing a spider that needs a load_url function that performs the following for me: Retry the URL if there is a temporary error, without leaking exceptions. Not leak memory or file handles Use HTTP-KeepAlive for speed (optional) URLGrabber looks great on the surface, but it has trouble. The first I hit a problem with too many fil...

OS/X mimetype handler

I'd like to write a small script that implements RFC4709 for OS/X. I started off by creating an application bundle that registers the application/xml+davmount mimetype and launches a simple python script. It doesn't make a lot of sense to me to make this a .app bundle, because the application is very short-lived, and it also doesn't se...

Best way to start, stop and send parameters to separate Python script from C++ application ?

I try to explain the situation: I have a QT application written in C++ and QT. This QT application starts a separate console C++ application that runs in the background. These two communicate using perhaps sockets, don't know yet. Console C++ application needs to start and stop my gnuradio python script. Also it needs to send parameter...

How to change variables in Python

Hello, I am trying to change a variable further down the program. I have a global variable declared at the start of the program and I want to change the variable in different functions down the program. I can do this by declaring the variable inside the function again but I would like to know is there a better way of doing this. Some te...

How to make phone calls using Python?

I'm writting a small python program to send voice file to other telephone. The phone is connected to pc over usb. How to make phone calls using Python? ...

What is The Pythonic Way for writing matching algorithm

I have this piece of code (should be self-explanatory; if not, just ask): for tr in completed_taskrevs: found = False for nr in completion_noterevs: if tr.description in nr.body: completion_noterevs.remove(nr) found = True break assert found How can I make it more pythonic? ...