python

Python regex for fixing Australian/New Zealand Phone Numbers

heya, I have a Python script that we're using to parse CSV files with user-entered phone numbers in it - ergo, there are quite a few weird format/errors. We need to parse these numbers into their separate components, as well as fix some common entry errors. Our phone numbers are for Sydney or Melbourne (Australia), or Auckland (New Zea...

create a lzma file in python

i need to create a lzma file with the existing .tar file and another metadata file to further create a zip file. ...

convert as rouund values [String(Math.round(65/30))]

String(Math.round(values/30))..am having values 65.i want the answer for that 3 not 2.1... wat is the solution ...

An inheritance example in python

I'm not clear how to pose this question. If I did, I'd probably be a lot closer to a solution.. I need some insight into inheritance. I want to make a custom subtype of float. But I want the instance of this subtype to re-evaluate it's value before performing any of the normal float methods (__add__,__mul__, etc..). In this example ...

Uninstantiated class attribute

Hello I need an uninstantiated class attribute and I am doing this: >>> class X: ... def __init__(self, y=None): ... self.y = list() Is this ok? If no, is there another way of doing it. I can't instantiate this attribute in __init__ cause I would be appending to this later. ...

GetWindowRect too small on Windows 7

The actual problem I'm trying to solve is, I want to automatically find out the size of the margins around windows. If you can find a better way, please by all means answer that instead of this. To do this I decided to take a screenshot of a test window and measure the margins. This is simple enough, as I expect no margins will ever be ...

Python solution for creating documentation from source files

Hi, I have lots of Python (2.x) source files in a quite large project. Most of them is quite well documented - in docstrings, or comments at the beginning of classes/methods. What I look for is a tool that would read those files and create a documentation out of it - best would be with class inheritance, method names and arguments and...

how do i make this python code less ugly

First of all python is an awesome language. This is my first project using python and I've made a ridiculous amount of progress already. There's no way that this code below is the best way to do this. What's the most idiomatic way write a class definition? class Course: crn = course = title = tipe = cr_hours = seats = instru...

How do I register a protocol to work with my program?

I'd like my program to be summoned when a browser tries to open a page with the protocol "tf2emp://xxxxx". The program will then have to download content based on the 5 digit number given in said protocol. My program is written in python, and I'm using wx for the gui. ...

What encoding does the unicode function in BeautifulSoup convert from?

When I use the unicode function in BeautifulSoup - what encoding does it convert to Unicode from? Does it automatically use the soup.originalEncoding? from BeautifulSoup import BeautifulSoup doc = "<html><h1>Heading</h1><p>Text" soup = BeautifulSoup(doc) print unicode(soup) Thanks ...

unknown array length in python ctypes

I'm calling a C function using ctypes from Python. It returns a pointer to a struct, in memory allocated by the library (the application calls another function to free it later). I'm having trouble figuring out how to massage the function call to fit with ctypes. The struct looks like: struct WLAN_INTERFACE_INFO_LIST { DWORD ...

BeautifulSoup doesn't give me Unicode

I'm using Beautiful soup to scrape data. The BS documentation states that BS should always return Unicode but I can't seem to get Unicode. Here's a code snippet import urllib2 from libs.BeautifulSoup import BeautifulSoup # Fetch and parse the data url = 'http://wiki.gnhlug.org/twiki2/bin/view/Www/PastEvents2007?skin=print.pattern' dat...

Python: Redis as session backend to Beaker

Anyone had success with using Redis as Beaker backend? Can you tell me link or library how to do it? I am looking for any library which does this but could not get anything out of google search. ...

Recommendation for python form validation library

I would like a form validation library that 1.separate html generation from form validation; 2.validation errors can be easily serialized, eg. dumped as a json object What form validation library would you choose in a python web project? ...

What is the best way to get Facebook Connect going with a Django app? (Given the new data permissions.)

Hey everyone, I'm new to Django and trying to set up a Facebook connected site. There seem to be three available options at the moment: Use middleware with PyFacebook. I was able to get the django-facebookconnect app going fairly easily and mod it to suit my needs, but it is currently unclear whether PyFacebook even supports extende...

To send Chat Invitation, to GTalk using Google App Engine(Python)?

How can i send Chat invitation over GTalk using Google App Engine(Python), i was searching for code in documentation of GAE, but i didnt get it. As i am new to Python, please post me the code too... ...

Python newbie - help needed in choosing modules/libraries

i am learning python.. i want to do certain kind of scripting in python.. like, i want to communicate 'wmic' commands through dos promt.. store the result a file.. access some sqlite database, take the data it has and compare with the result i stored.. now, what i dont get is that, how should i proceed? is there any specific frameworks o...

Python: How to find path to the script running a python script.

Lets say i have a python script at homedir/codes/py/run.py I also have a bash script at homedir/codes/run.sh This bash script runs run.py by python py/run.py. The thing is that i need to be able to find out, in run.py, the path to the calling script run.sh. If run.sh is run from its own directory, i can just use os.getcwd(). But run.sh ...

Scripting Languages

I am looking for a good scripting language to link to my program. I am looking for 2 important attributes: Scripting language should be hard linked into the executable (not requiring 3rd party installations). This is important to me to simplify distribution. Scripting should allow some run-time debugging option (When running a script ...

catch specific HTTP error in python

I want to catch a specific http error and not any one of the entire family.. what I was trying to do is -- import urllib2 try: urllib2.urlopen("some url") except urllib2.HTTPError: <whatever> but what I end up is catching any kind of http error, but I want to catch only if the specified webpage doesn't exist!! probably that's HT...