I want to have a python class that just acts as a wrapper for another python class.
Something like this
class xxx:
name = property( fset=lambda self, v: setattr(self.inner, 'name', v), fget=lambda self: getattr(self.inner, 'name' ))
def setWrapper( self, obj )
self.inner = obj
So when someone says xxx().x = 'hello' I ...
Hello,
I just pulled from my github and tried to setup my application on my Ubuntu (I originally ran my app on a Mac at home).
I re-created the database and reconfigured the settings.py -- also update the template locations, etc.
However, when I run the server "python manage.py runserver" get an error that says:
ImportError: cannot i...
Using Python's Networkx library, I created an undirected graph to represent a relationship network between various people. A snippet of my code is below:
import networkx as nx
def creategraph(filepath):
G=nx.Graph()
#All the various nodes and edges are added in this stretch of code.
return G
From what I understand, eac...
I'm trying to use the Python profiler to speed up my code. I've been able to identify the specific function where nearly all of the time is spent, but I can't figure out where in that function the time is being spent.
Below I have the profile output, which shows that "appendBallot" is the primary culprit and consumes nearly 116 seconds...
Hello,
I am currently running a high-traffic python/django website using Apache and mod_wsgi. I'm hoping that there's a faster webserver configuration out there, and I've heard a fair number of recommendations for lighttpd and fastcgi. Is this setup faster than apache+mod_wsgi for serving dynamic django pages (I'm already convinced that...
Need to use PGP/GnuPG to encrypt.can suggest what the Python packages to use that.
for PGP encryption i.e. on the other side is PGP used to decrypt.
...
I've started using Eclipe+PyDev as an environment for developing my first app for Google App Engine. Eclipse is configured according to this tutorial.
Everything was working until I start to use memcache. PyDev reports the errors and I don't know how to fix it:
Error: Undefined variable from import: get
How to fix this?
Sure, it is ...
I want to mimic a piece of C code in Python with ctypes, the code is something like:
typedef struct {
int x;
int y;
} point;
void copy_point(point *a, point *b) {
*a = *b;
}
in ctypes it's not possible to do the following:
from ctypes import *
class Point(Structure):
_fields_ = [("x", c_int),("y", c_int)]
def copy_point(a,...
I have created a temporary file.
Added some data to the file created.
Saved it and then trying to delete it.
But I am getting WindowsError. I have closed the file after editing it. How do I check which other process is accessing the file.
C:\Documents and Settings\Administrator>python
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:...
import cgi
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
class Greeting(db.Model):
author = db.UserProperty()
content = db.StringProperty(multiline=True)
date = db.DateTimeProperty(auto_now_add=True)
cla...
I am a beginner in python. I want to Create new List object in python.
My Code:
recordList=[]
mappedDictionay={}
sectionGroupName= None
for record in recordCols:
item = record
print item
if not sectionGroupName == record[0]:
sectionGroupName = record[0]
del recordList[0:] # Here I want to create new list...
I have a wxPython app which has many worker threads, idle event cycles, and many other such event handling code which can consume CPU, for now when app is not being interacted with consumes about 8-10% CPU.
Question:
Is there a tool which can tell which part/threads of my app is consuming most CPU? If there are no such generic tools, I...
In my quest to understand queries to Django models I've been trying to get the last 3 added valid Avatar models with a query like:
newUserAv = Avatar.objects.filter(valid=True).order_by("date")[:3]
However this gives me the first three avatars added ordered by date. I'm sure this is so simple but I've had trouble finding it in the Dja...
Hello,
I've built this model which contains a generic foreign key:
class MyModel(models.Model):
content_type = models.ForeignKey(ContentType, verbose_name=_('content type'))
object_id = models.PositiveIntegerField(_('object id'))
content_object = generic.GenericForeignKey('content_type', 'object_id')
Next I've made a gene...
So, I've got an application that uses Twisted + Stomper as a STOMP client which farms out work to a multiprocessing.Pool of workers.
This appears to work ok when I just use a python script to fire this up, which (simplified) looks something like this:
# stompclient.py
logging.config.fileConfig(config_path)
logger = logging.getLogger(_...
Hi,
I tried installing M2Crypto and facing problems. I don't want to force my customers to use such libraries which are difficult to install. So, I thought I would give pyOpenSSL a try. I am able to get the public key from pem certificate but am not able to find any way to verify the signature.
...
I want to find string similarity between two strings. This page ha sexmaple of some of them. Python has an implemnetation of Levenshtein algorithm. Is there a better algorithm, (and hopefully a python library), under these contraints.
I want to do fuzzy matches between strings. eg matches('Hello, All you people', 'hello, all You peopl'...
I have an instance of a Connection (required to DB API 2.0-compliant), but I don't have the module from which it was imported. The problem is that I am trying to use named parameters, but I don't know which paramstyle to use.
Since paramstyle is a module-level constant, I can't just ask the Connection. I tried using inspect.getmodule() ...
I am trying to install pysqlite and have troubles with that. I found out that the most probable reason of that is missing sqlite headers and I have to install them. My platform: CentOS release 5.3 (Final). I have Python-2.6.2.
I also found out that I need .rpm files. As far as I have them I execute:
rpm -i sqlite3-devel-3.n.n.n.rpm
a...
Hi all,
I've a web application that accesses multiple controller classes based on the parameters it is passed. For some of the controllers, I want users to authenticate themselves (by simple HTTP authentication), and for some I want public access.
Is there a way to make this happen? In my .htaccess file, I now have
AddHandler mod_pyth...