python

python library for converting plain text (ASCII) into GSM 7-bit character set?

Is there a python library for encoding ascii data to 7-bit GSM character set (for sending SMS)? -- mks -- ...

Beginner python - stuck in a loop

I have two begininer programs, both using the 'while' function, one works correctly, and the other gets me stuck in a loop. The first program is this; num=54 bob = True print('The guess a number Game!') while bob == True: guess = int(input('What is your guess? ')) if guess==num: print('wow! You\'re awesome!') ...

ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction

Hi guys, i have this simple type from an external webservice: <xsd:element name="card_number" maxOccurs="1" minOccurs="1"> <xsd:simpleType> <xsd:restriction base="tns:PanType"> <xsd:pattern value="\d{16}"></xsd:pattern> <xsd:whiteSpace value="collapse"></xsd:whiteSpace> </xsd:restriction> </xsd:simpleType> </xsd:...

Matplotlib installation problems

Hi, I need to install matplotlib in a remote linux machine, and I am a normal user there. I downlodad the source and run python setup.py build but I get errors, related with numpy, which is not installed, so I decieded to install it first. I download and compile with python setup.py build My question now is, how do I tell to te...

find the colour name from a hexadecimal colour code

Hi , i want to find the name of a colour from the hexadecimal colour code. When i get a hex colour code i want to find the most matching colour name. for example for the code #c06040 , how to find out if it is a shade of brown, blue or yellow ?. so that i can find the colour of an object in the image without human intervention. Is the...

Python list is not the same reference

This is the code: L=[1,2] L is L[:] False Why is this False? ...

Django QuerySet ordering by number of reverse ForeignKey matches

I have the following Django models: class Foo(models.Model): title = models.CharField(_(u'Title'), max_length=600) class Bar(models.Model): foo = models.ForeignKey(Foo) eg_id = models.PositiveIntegerField(_(u'Example ID'), default=0) I wish to return a list of Foo objects which have a reverse relationship with Bar objects...

etree.findall: 'OR'-lookup?

I want to find all stylesheet definitions in a XHTML file with lxml.etree.findall. This could be as simple as elems = tree.findall('link[@rel="stylesheet"]') + tree.findall('style') But the problem with CSS style definitions is that the order matters, e.g. <link rel="stylesheet" type="text/css" href="/media/css/first.css" /> <style>b...

How to retrieve objects using a class attribute in python with zodb

I have a class in which there's a attribute Name of the person.Based on this name I want to retireve that particular object by comparing parameters and return this object in a function....newbie here ...

Is there a library in Python that can convert user-dates to timestamp?

If the month is: "12" Day is: "05" Year is: "2010" Can this be converted into a timestamp somehow, in a very simple way? ...

[Python] Detect destination of shortened, or "tiny" url

I have just scraped a bunch of Google Buzz data, and I want to know which Buzz posts reference the same news articles. The problem is that many of the links in these posts have been modified by URL shorteners, so it could be the case that many distinct shortened URLs actually all point to the same news article. Given that I have millio...

Django '<object> matching query does not exist' when I can see it in the database

My model looks like this: class Staff(models.Model): StaffNumber = models.CharField(max_length=20,primary_key=True) NameFirst = models.CharField(max_length=30,blank=True,null=True) NameLast = models.CharField(max_length=30) SchoolID = models.CharField(max_length=10,blank=True,null=True) AutocompleteName = models.Char...

urllib2 multiple Set-Cookie headers in response

I am using urllib2 to interact with a website that sends back multiple Set-Cookie headers. However the response header dictionary only contains one - seems the duplicate keys are overriding each other. Is there a way to access duplicate headers with urllib2? ...

video player with qt phonon (using python)

hi, I am working on Windows xp and am trying to get a simple video player running. I am trying to use Phonon::VideoPlayer module for this. I am connecting the signal as connect(self.player,SIGNAL("finished()"),self.player.deleteLater) and then , when the Play button is pressed, it makes the following call: self.player.play(Phono...

how to run python scripts from other script and have thier root in my root

hello all i have a module "B", i want to run it from a script "C", and i want to call global variables in "B", as they wer in "C" root, another problem that is if i imported sys in "B" when i run "C" it doesnt see sys # NameError: global name 'sys' is not defined # what shall i do? ...

What is a Pythonic way to get a list of tuples of all the possible combinations of the elements of two lists?

Suppose I have two differently-sized lists a = [1, 2, 3] b = ['a', 'b'] What is a Pythonic way to get a list of tuples c of all the possible combinations of one element from a and one element from b? >>> print c [(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b'), (3, 'a'), (3, 'b')] The order of elements in c does not matter. The solution wi...

How to use CrawlSpider from scrapy to click a link with javascript onclick?

I want scrapy to crawl pages where going to the next one link looks like this: Next Will scrapy be able to interpret javascript code of that? With livehttpheaders extension I found out that clicking Next generates a POST with a really huge piece of "garbage" starting like this: encoded_session_hidden_map=H4sIAAAAAAAAALWZXWwj1RXHJ9n ...

How to create a custom admin configuration panel in Django?

Hi, I would like to create a configuration panel for the homepage of the web-app I'm designing with Django. This configuration panel should let me choose some basic options like highlighting some news, setting a showcase banner, and so on. Basically I don't need an app with different rows, but just a panel page with some configuration op...

How to spell check python docstring with emacs ?

I'd like to run a spell checker on the docstrings of my Python code, if possible from within emacs. I've found the ispell-check-comments setting which can be used to spell check only comments in code, but I was not able to target only the docstrings which are a fairly python-specific thing. ...

Open Source CMS with linked sub-sections and users

I work at a small college that wants to make "sites" for all of the academic departments (~30). I managed to talk them out of their original idea: 30 individual Wordpress installations. What a maintenance nightmare! What I'm looking for is a CMS (preferably Python or PHP, as those are my areas of expertise) that can automagically creat...