python

Does PySVN need Subversion installed?

I have python script that uses pysvn and checks out or updates a local copy obtained also from a local repo. client.checkout(url, path, revision=pysvn.Revision(pysvn.opt_revision_kind.number, RevNumber), ignore_externals=False) I am running this on a windows machine in which I haven't installed subversion. The svnsync used to obtain ...

Trouble with rdfstore with mysql - how to debug?

I have a mysql server running and can connect to it from my Django ORM. Can't connect using the rdflib functionality. How can I debug this problem? Thanks. rdflib 2.4.2, python 2.6, MySQL Community 5.1.42 Trace: configString = "host=localhost,user=root,password=...,db=..." print configString host=localhost,user=root,password=.....

Python: question regarding split() method

What is the point of '/segment/segment/'.split('/') returning ['', 'segment', 'segment', '']? Notice the empty elements. If you're splitting on a delimiter that happens to be at position one and at the very end of a string, what extra value does it give you to have the empty string returned from each end? ...

efficiently knowing if intersection of two list is empty or not, in python

Hi! Suppose I have two lists, L and M. Now I want to know if they share an element. Which would be the fastest way of asking (in python) if they share an element? I don't care which elements they share, or how many, just if they share or not. For example, in this case L = [1,2,3,4,5,6] M = [8,9,10] I should get False, and here: L...

Why doesn't super(Thread, self).__init__() work for a threading.Thread subclass?

Hi, Small question. Every object I know of in python can take care of its base class initialization by calling super(BaseClass, self).__init__() This doesn't seem to be the case with a subclass of threading.Thread, since if I try this in SubClass.__init__(), I get: RuntimeError: thread.__init__() not called What gives? I looked ...

Complex SQL optimization vs. general-purpose language

How might I optimize this query? The schema: mysql> show columns from transactionlog; +---------------+-------------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------------------------...

How to Handle EOFError for raw_input() in python in Mac OS X

My python program has two calls to raw_input() The first raw_input() is to take multiline input from the user. The user can issue Ctrl+D (Ctrl+Z in windows) for the end of input. Second raw_input() should take another input from user with (y/n) type prompt. Unfortunately (in Mac OS X only?), second raw_input() raises EOFError when th...

How do I update my version of Django?

I currently have it installed and it's running a website. http://www.djangoproject.com/download/ This is the new version. How do I upgrade it? (How do I install the new version over my current one?) ...

What is the best OAUTH/Django library?

I use pyFacebook (which is not oauth) for facebook/django. What about oauth? What library do you guys absolutely recommend? I'm trying to implement a login system for LinkedIn: http://developer.linkedin.com/docs/DOC-1008#Authorization_in_the_LinkedIn_APIs ...

python file reading

I have file /tmp/gs.pid with content client01: 25778 I would like retrieve the second word from it. ie. 25778. I have tried below code but it didn't work. >>> f=open ("/tmp/gs.pid","r") >>> for line in f: ... word=line.strip().lower() ... print "\n -->" , word ...

Convert "little endian" hex string to IP address in Python

What's the best way to turn a string in this form into an IP address: "0200A8C0". The "octets" present in the string are in reverse order, i.e. the given example string should generate 192.168.0.2. ...

how to use array in django

Hi , I have a db table which has a integer array.But how can i add this field in my model .I tried writing it using IntegerField but on save it is giving error int() argument must be a string or a number, not 'list how can i add this field to my model.I m using this field in my views.py so i need to add it inmy model.Any suggestions...

Importing globally and locally

I created a module which is going to be used in several python scripts. The structure is as follows: Main file: import numpy as np from mymodule import newfunction f = np.arange(100,200,1) a = np.zeros(np.shape(f)) c = newfunction(f) mymodule.py: def newfunction(f): import numpy as np b = np.zeros(np.shape(f)) return b ...

Getting python MySQLdb to run on Ubuntu

I created a virtualbox with a fresh install of ubuntu 9.10. I am trying to get MySQLdb to run on python but I'm failing at the import MySQLdb I first tried sudo easy_install MySQL_python-1.2.3c1-py2.6-linux-i686.egg and then sudo apt-get install python-mysqldb. Both apparently installed ok, but gave me the following error message whe...

How to turn a SVG image to a SDL surface or an array of RGBA pixels with python?

I'm guessing it has to be done with the aid of some sort of framework. Google gives libCairo as the most common result, but that is way too many dependencies. I mean something that would work on Win/Lin/OSX, be non-GPL, python-compatible, freely re-distributable. And preferably a few hundred KB in size. Thing is, it doesn't even have t...

no procedural code and non mvc in ruby and python?

i know that these 2 languages require oop. but inside the classes, could you have procedural code? and for the mvc part, that pattern comes with their frameworks right? nothing to do with the actual language itself? ...

open flash chart in python/django

I am using open flash chart for chart development. I need to put my image in the chart as in this example. I am using python for the development, and I can't find help anywhere about it. Can anyone give me an example with the created json so that I can create for my own charts. ...

What does pk__in mean in Django?

Model.objects.filter(pk__in=[list of ids]) and Model.objects.filter(pk__in=[1,2,3]) How do I show this data in a template? def xx(request): return HttpResponse(Model.objects.filter(pk__in=[1,2,3])) ...

How to automate updating a trac wiki page?

I have a trac wiki page I'd like to update automatically on a regular basis (say, once an hour) with data fetched by a script. I can get the script to generate the wiki markup. How would you then upload that to the trac page? I want to replace the whole body of the page. I would prefer a solution in python, as the rest of the stack (t...

Problem writing a database query

I have two models, Location and Event, that are linked by ForeignKey on the Event model. The models break down as follows: class Location(models.Model): city = models.CharField('city', max_length=25) slug = models.SlugField('slug') class Event(models.Model): location = models.ForeignKey(Location) title = models.CharFiel...