python

Python - downloading a file over HTTP with progress bar and basic authentication

I'm using urllib.urlretrieve to download a file, and implementing a download progress bar using the reporthook parameter. Since urlretrieve doesn't directly support authentication, I came up with import urllib def urlretrieve_with_basic_auth(url, filename=None, reporthook=None, data=None, username="", p...

What is __init__.py for?

What is __init__.py for in a python source directory? ...

How do I create a webpage with buttons that invoke various Python scripts on the system serving the webpage?

I'm a hobbyist (and fairly new) programmer who has written several useful (to me) scripts in python to handle various system automation tasks that involve copying, renaming, and downloading files amongst other sundry activities. I'd like to create a web page served from one of my systems that would merely present a few buttons which wou...

Setting up Python on Windows/ Apache?

I want to get a simple Python "hello world" web page script to run on Windows Vista/ Apache but hit different walls. I'm using WAMP. I've installed mod_python and the module shows, but I'm not quite sure what I'm supposed to do in e.g. http.conf (things like AddHandler mod_python .py either bring me to a file not found, or a forbidden, o...

Are there any good 3rd party GUI products for Python?

In .Net you have companies like DevEpxress, and Infragistics that offer a range of GUI widgets. Is there any market like that for Python GUI widgets? I'm thinking specifically about widgets like the DevExpress xtraGrid Suite. Edit 01-16-09: For Example: http://www.devexpress.com/Downloads/NET/OnlineDemos.xml http://demos.devexpress....

How do I determine the size of an object in Python?

In C, we can find the size of an int, char, etc. I want to know how to get size of objects like a string, integer, etc. in Python. Related question: How many bytes per element are there in a Python list (tuple)? I am using an XML file which contains size fields that specify the size of value. I must parse this XML and do my coding. Whe...

Is there a tool for converting VB to a scripting language, e.g. Python or Ruby?

I've discovered VB2Py, but it's been silent for almost 5 years. Are there any other tools out there which could be used to convert VB6 projects to Python, Ruby, Tcl, whatever? ...

How can I split a url string up into separate parts in Python?

Hi all. I decided that I'll learn python tonight :) I know C pretty well (wrote an OS in it) so I'm not a noob in programming so everything in python seems pretty easy, but I don't know how to solve this problem : let's say I have this address: http://example.com/random/folder/path.html Now how can I create two strings from this, one c...

How to check if a file can be created inside given directory on MS XP/Vista?

I have a code that creates file(s) in user-specified directory. User can point to a directory in which he can't create files, but he can rename it. I have created directory for test purposes, let's call it C:\foo. I have following permissions to C:\foo: Traversing directory/Execute file Removing subfolders and files Removing Re...

Executing command line programs from within python

I'm building a web application that will is going to manipulate (pad, mix, merge etc) sound files and I've found that sox does exactly what I want. Sox is a linux command line program and I'm feeling a little uncomfortable with having the python web app starting new sox processes on my server on a per request basis. Example: import os...

Python Path

I am installing active python, django. I really dont know how to set the python path in vista environment system. first of all will it work in vista. ...

Deleting lines from wx.TextCtrl

I am using a wx.TextCtrl to output text from a network daemon. As the output is quite verbose, the size of text in the TextCtrl can become huge (BTW is there any limitation on the size of the contents of a TextCtrl?) I would like to delete the top N lines from the TextCtrl when TextCtrl.GetNumberOfLines() exceeds a predefined treshold. W...

Cookie Problem in Python

I'm working on a simple HTML scraper for Hulu in python 2.6 and am having problems with logging on to my account. Here's my code so far: import urllib import urllib2 from cookielib import CookieJar #make a cookie and redirect handlers cookies = CookieJar() cookie_handler= urllib2.HTTPCookieProcessor(cookies) redirect_handler= urllib2....

ImportError when using Google App Engine

When I add the following line to Google's helloworld example: from reportlab.pdfgen import canvas I get the following error: <type 'exceptions.ImportError'>: No module named reportlab.pdfgen I can get at the reportlab.pdfgen library from the python console. Why can't I get at it from google's dev_appserver? ...

Best cross platform XML parsers for Python

On a project I'm working on we're using LibXML2 (import lxml) because it has Objectify. But we're finding that getting it to work in OSX is an incredibly involved process. Does anyone have suggestions for clean cross platform xml libraries that don't have excessive dependencies on C libraries? ...

What's the most efficient way to access sibling dictionary value in a Python dict?

In Python, I've got a list if dictionaries that looks like this: matchings = [ {'id': 'someid1', 'domain': 'somedomain1.com'}, {'id': 'someid2', 'domain': 'somedomain2.com'}, {'id': 'someid3', 'domain': 'somedomain3.com'} ] and, I have a variable: the_id = 'someid3' What's the most efficient way to retrieve the domain v...

What is the correct way to backup ZODB blobs?

I am using plone.app.blob to store large ZODB objects in a blobstorage directory. This reduces size pressure on Data.fs but I have not been able to find any advice on backing up this data. I am already backing up Data.fs by pointing a network backup tool at a directory of repozo backups. Should I simply point that tool at the blobstorag...

Making a method private in a python subclass

Is it possible to make a public method private in a subclass ? I don't want other classes extending this one to be able to call some of the methods . Here is an example : class A: def __init__(self): #do something here def method(self): #some code here class B(A): def __init__(self): A.__init__(self...

Python and Bluetooth/OBEX

Is there any Python libraries that will let me send files with OBEX (OBject EXchange) and that works cross-platform (Windows, OS X, Linux)? I have found Lightblue, which works for Linux and OS X, but not for Windows. If none such lib exists, are there any decent ones that only works in Windows? ...

Creating a gradient fill in a PDF file using reportlab

Is it possible to create a gradient fill in a PDF using ReportLab (python)? ...