python

Python: How do you login to a page and view the resulting page in a browser?

Hey there, I've been googling around for quite some time now and can't seem to get this to work. A lot of my searches have pointed me to finding similar problems but they all seem to be related to cookie grabbing/storing. I think I've set that up properly, but when I try to open the 'hidden' page, it keeps bringing me back to the login ...

When and why are you planning to upgrade to Python 3.x?

Python 3.x (aka Python 3000, Py3k, etc) is now available. When and why are you planning on porting your project or code to the new Python? edit: I'm particularly interested in any features that don't exist in 2.6 that make porting worth it. Right now seems like a lot of negatives (x hasn't been ported yet), but I don't know what people ...

Looking for knowledge base integrated with bug tracker in python

Ok, I am not sure I want to use Request Tracker and RTFM, which is a possible solution. I'd like to have a knowledge base with my bug tracker/todo list , so that when I solve a problem, I would have a record of its resolution for myself or others later. What python based solutions are available? ...

What's the difference between dict() and {}?

So let's say I wanna make a dictionary. We'll call it d. But there are multiple ways to initialize a dictionary in Python! For example, I could do this: d = {'hash': 'bang', 'slash': 'dot'} Or I could do this: d = dict(hash='bang', slash='dot') Or this, curiously: d = dict({'hash': 'bang', 'slash': 'dot'}) Or this: d = dict([['...

Uninitialized value in Python?

What's the uninitialized value in Python, so I can compare if something is initialized, like: val if val == undefined ? EDIT: added a pseudo keyword. EDIT2: I think I didn't make it clear, but say val is already there, but nothing is assigned to it. Duplicate: Just declaring a variable in Python? ...

Just declaring a variable in Python?

Is it possible to just declaring a variable in Python, like so?: var so that it's gonna be initialized to None? It seems like python allows this, but as soon as you access it, it crashes. Is this possible? If not, why? EDIT: I wanna do this for cases like this: value for index in sequence: if value == None and conditionMet: ...

Using norwegian letters æøå in python

Hello I'm learning python and PyGTK now, and have created a simple Music Organizer. http://pastebin.com/m2b596852 But when it edits songs with the Norwegian letters æ, ø, and å it's just changing them to a weird character. So is there any good way of opening or encode the names into utf-8 characters? Two relevant places from the above ...

How to recover a broken python "cPickle" dump?

I am using rss2email for converting a number of RSS feeds into mail for easier consumption. That is, I was using it because it broke in a horrible way today: On every run, it only gives me this backtrace: Traceback (most recent call last): File "/usr/share/rss2email/rss2email.py", line 740, in <module> elif action == "list": list(...

How to Make an Image Uniform Brightness (using Python/PIL)

I want to take an image of a document that was photographed and make it look like it was scanned. Since a scanner will put a constant light source over the whole document, I want to achieve that effect on a photo of a document. The desired effect would be to remove any shadows or areas of low light (or at least make them less noticeabl...

Hierarchy traversal and comparison modules for Python?

I deal with a lot of hierarchies in my day to day development. File systems, nested DAG nodes in Autodesk Maya, etc. I'm wondering, are there any good modules for Python specifically designed to traverse and compare hierarchies of objects? Of particular interest would be ways to do 'fuzzy' comparisons between two nearly identical hier...

How can I improve this "register" view in Django?

I've got a Django-based site that allows users to register (but requires an admin to approve the account before they can view certain parts of the site). I'm basing it off of django.contrib.auth. I require users to register with an email address from a certain domain name, so I've overridden the UserCreationForm's save() and clean_email(...

box drawing in python

Platform: WinXP SP2, python 2.5.4.3. (activestate distribution) Has anyone succeded in writing out box drawing characters in python? When I try to run this: print u'\u2500' print u'\u2501' print u'\u2502' print u'\u2503' print u'\u2504' All tips appreciated. What am I doing wrong ? Does python support full unicode ? Is it possible at...

Python: defaultdict became unmarshallable object in 2.6?

Did defaultdict's become not marshal'able as of Python 2.6? The following works under 2.5, fails under 2.6 with "ValueError: unmarshallable object" on OS X 1.5.6, python-2.6.1-macosx2008-12-06.dmg from python.org: from collections import defaultdict import marshal dd = defaultdict(list) marshal.dump(dd, file('/tmp/junk.bin','wb') ) ...

Python: Running all unit tests inside a package

I'm trying to hack my through an open source python project (namely: jinja2), When I say "I'm hacking my way through", I mean I don't really know what I'm doing, so I want to run unittests whenever I change something to make sure I'm not breaking something major! There's a package full of unit tests (if you want to have a look, it's h...

Status of shift and caps lock in Python

I'm writing a TkInter application using Python 2.5 and I need to find out the status of the caps lock and shift keys (either true or false). I've searched all over the net but cant find a solution. ...

How do i go about writting a program to send and receive sms using python?

I have looked all over the net for a good library to use in sending and receiving sms's using python but all in vain! Are there GSM libraries for python out there? ...

Python Tkinter Shell to GUI ?

I have created a program that prints results on command line. (It is server and it prints log on command line.) Now, I want to see the same result to GUI . How can I redirect command line results to GUI? Please, suggest a trick to easily transform console application to simple GUI. NOTE:It should work on Linux And Windows. ...

Extract array from list in python

If I have a list like this: >>> data = [(1,2),(40,2),(9,80)] how can I extract the the two lists [1,40,9] and [2,2,80] ? Of course I can iterate and extract the numbers myself but I guess there is a better way ? ...

Best continuously updated resource about python web "plumbing"

I'm a programmer in Python who works on web-applications. I know a fair bit about the application level. But not so much about the underlying "plumbing" which I find myself having to configure or debug. I'm thinking of everything from using memcached to flup, fcgi, WSGI etc. When looking for information about these, online, Google typi...

How to write a function that takes a string and prints the letters in decreasing order of frequency?

I got this far: def most_frequent(string): d = dict() for key in string: if key not in d: d[key] = 1 else: d[key] += 1 return d print most_frequent('aabbbc') Returning: {'a': 2, 'c': 1, 'b': 3} Now I need to: reverse the pair sort by number by decreasing order only print the le...