python

Python packages and egg-info directories

Can someone explain how egg-info directories are tied to their respective modules? For example, I have the following: /usr/local/lib/python2.5/site-packages/quodlibet/ /usr/local/lib/python2.5/site-packages/quodlibet-2.0.egg-info/ I'm assuming the egg-info directory is to make the corresponding module visible to setuptools (easy_insta...

Putting a pyCurl XML server response into a variable (Python)

I'm a Python novice, trying to use pyCurl. The project I am working on is creating a Python wrapper for the twitpic.com API (http://twitpic.com/api.do). For reference purposes, check out the code (http://pastebin.com/f4c498b6e) and the error I'm getting (http://pastebin.com/mff11d31). Pay special attention to line 27 of the code, which ...

Message Box in Python

Is there a UI library to create a message box or input box in python? ...

Download image file from the HTML page source using python?

I am writing a scraper that downloads all the image files from a HTML page and saves them to a specific folder. all the images are the part of the HTML page. ...

What's the difference between scgi and wsgi?

What's the difference between these two? Which is better/faster/reliable? ...

Python MySQL Statement returning Error

hey, I'm very new to all this so please excuse stupidity :) import os import MySQLdb import time db = MySQLdb.connect(host="localhost", user="root", passwd="********", db="workspace") cursor = db.cursor() tailoutputfile = os.popen('tail -f syslog.log') while 1: x = tailoutputfile.readline() if len(x)==0: ...

'Snippit' based django semi-CMS

I remember reading somewhere on the internets about a half-assed tiny django CMS app, which was basically built on 'snippets' of text. The idea was, that in the admin, you make a snippet (say a description of a product), give it a name (such as 'google_desc') and call it in a template with something like {% snippet google_desc %} and ba...

How can I make a fake "active session" for gconf?

I've automated my Ubuntu installation - I've got Python code that runs automatically (after a clean install, but before the first user login - it's in a temporary /etc/init.d/ script) that sets up everything from Apache & its configuration to my personal Gnome preferences. It's the latter that's giving me trouble. This worked fine in Ub...

Python vs Groovy vs Ruby? (based on criteria listed in question)

Considering the criteria listed below, which of Python, Groovy or Ruby would you use? Criteria (Importance out of 10, 10 being most important) Richness of API/libraries available (eg. maths, plotting, networking) (9) Ability to embed in desktop (java/c++) applications (8) Ease of deployment (8) Ability to interface with DLLs/Shared Lib...

Java equivelent to pyftpdlib?

Is there a good Java alternative to pyftpdlib? I am looking for an easy to setup and run embedded ftp server. ...

Python: wrapping method invocations with pre and post methods

I am instantiating a class A (which I am importing from somebody else, so I can't modify it) into my class X. Is there a way I can intercept or wrape calls to methods in A? I.e., in the code below can I call x.a.p1() and get the output X.pre A.p1 X.post Many TIA! class A: # in my real application, this is an imported class ...

Why are Exceptions iterable?

I have been bitten by something unexpected recently. I wanted to make something like that: try : thing.merge(iterable) # this is an iterable so I add it to the list except TypeError : thing.append(iterable) # this is not iterable, so I add it Well, It was working fine until I passed an object inheriting from Exception which ...

Django models - how to filter number of ForeignKey objects

I have a models A and B, that are like this: class A(models.Model): title = models.CharField(max_length=20) (...) class B(models.Model): date = models.DateTimeField(auto_now_add=True) (...) a = models.ForeignKey(A) Now I have some A and B objects, and I'd like to get a query that selects all A objects that have less then 2 ...

Python filter/remove URLs from a list

Hi. I have a text file of URLs, about 14000. Below is a couple of examples: http://www.domainname.com/pagename?CONTENT_ITEM_ID=100&param2=123 http://www.domainname.com/images?IMAGE_ID=10 http://www.domainname.com/pagename?CONTENT_ITEM_ID=101&param2=123 http://www.domainname.com/images?IMAGE_ID=11 http://www.domainname.com/page...

Slicing URL with Python

Hi. I am working with a huge list of URL's, you guys have already helped me :) Just a quick question I have trying to slice a part of the URL out, see below: http://www.domainname.com/page?CONTENT_ITEM_ID=1234&param2&param3 How could I slice out: http://www.domainname.com/page?CONTENT_ITEM_ID=1234 Sometimes there is more ...

Django: Overriding verbose_name for AutoField without dropping the model.

I am using 0.97-pre-SVN-unknown release of Django. I have a model for which I have not given any primary_key. Django, consequently, automatically provides an AutoField that is called "id". Everything's fine with that. But now, I have to change the "verbose_name" of that AutoField to something other than "id". I cannot override the "id" ...

How to find out if a lazy relation isn't loaded yet, with SQLAlchemy?

With SQLAlchemy, is there a way to know beforehand whether a relation would be lazy-loaded? For example, given a lazy parent->children relation and an instance X of "parent", I'd like to know if "X.children" is already loaded, without triggering the query. ...

Did anyone try Portable Python ?

I have recently discovered Portable Python as a very interesting tool. I am a linux user, and I am frutstrated when I come to machines that does not come "battery included". This is cool because it's non obtrusive : I don't want to install Python in any windows that passed in my hands... But I don't know if it's reliable. If I make a ...

python, functions running from a list and adding to a list through functions

How do I run a function on a loop so all the results go straight into a list and is there a way to run a function which acts on all the values in a list? ...

python smtplib

Hey I have a windows server running python CGI scripts and I'm having a little trouble with smtplib. The server is running python 2.1 (unfortunately and I can not upgrade it). Anyway I have the following code: session = smtplib.SMTP("smtp-auth.ourhosting.com", 587) session.login(smtpuser, smtppass) and it's giving me this err...