python

Json unicode decoding in python's simplejson

I can't decode json strings like this: "\u0e4f\u0361\u032f\u0e4f" >>> import simplejson >>> simplejson.loads('"\u0e4f\u0361\u032f\u0e4f"', encoding='utf8') u'\u0e4f\u0361\u032f\u0e4f' However php json_decode works fine: json_decode('"\u0e4f\u0361\u032f\u0e4f"'); What am I doing wrong? ...

How do i set proxy settings for python pydelicios module

I have downloaded python pydelicious module to connect to delicious API, but when i try to add a link to delicious the module fails with socket error 10060. I believe this is caused by my proxy setting cause am going through one, how do i make pydelicious see my proxy and use it? Gath ...

django threadedcomments

Hi folks, I would like to setup a comment systems on my site, using django threadedcomments, and I follow all the steps in the Tutorial, however, I get the following error: No module named newforms.util I am not sure what causing this issue, here is my configuration: #settings.py INSTALLED_APPS = ( 'django.contrib.admin', 'dj...

Looking to reimplement build toolchain from bash/grep/sed/awk/(auto)make/configure to something more sane (e.g. boost.build, etc)

I currently maintain a few boxes that house a loosely related cornucopia of coding projects, databases and repositories (ranging from a homebrew *nix distro to my class notes), maintained by myself and a few equally pasty-skinned nerdy friends (all of said cornucopia is stored in SVN). The vast majority of our code is in C/C++/assembly ...

Appengine Python Bulk Export error

This seems to run for a few thousand records then dies on its arse import datetime import time from google.appengine.ext import db from google.appengine.tools import bulkloader from google.appengine.api import datastore_types class SearchRec(db.Model): WebSite = db.StringProperty() WebPage = db.StringProperty() DateStamp = db.Da...

How to use a callable as the setup with timeit.Timer?

I want to time some code that depends on some setup. The setup code looks a little like this: >>> b = range(1, 1001) And the code I want to time looks vaguely like this: >>> sorted(b) Except my code uses a different function than sorted. But that ain't important right now. Anyhow, I know how to time this code as long as I pass i...

small python code refactor

I am having this piece of code, which in my opinion is fairly ugly and I am wondering how it can be done better: if dic.get(key, None) is None: dic[key] = None Points for elegance ;-) ...

parsing .properties file in Python

configparser raises an exception if one parses a simple .properties (key/value) file which lacks section headers. Is there some workaround? ...

Redirect logging output using custom logging handler

Hi Guys, I'm using a module in my python app that writes a lot a of messages using the logging module. Initially I was using this in a console application and it was pretty easy to get the logging output to display on the console using a console handler. Now I've developed a GUI version of my app using wxPython and I'd like to display a...

Is there an intelligent editor for ReST files?

I'm just learning Sphinx, and I need to edit ReST files. Is there an intelligent editor for it? Like, an editor that gives me code coloration, easy indentation, code completion (hopefully), etc. ...

Handling KeyboardInterrupt when working with PyGame

I have written a small Python application where I use PyGame for displaying some simple graphics. I have a somewhat simple PyGame loop going in the base of my application, like so: stopEvent = Event() # Just imagine that this eventually sets the stopEvent # as soon as the program is finished with its task. disp = SortDisplay(algorithm...

How to achieve interaction between GUI class with logic class

Im new to GUI programming, and haven't done much OOP. Im working on a basic calculator app to help me learn GUI design and to brush up on OOP. I understand that anything GUI related should be kept seperate from the logic, but Im unsure how to implement interaction between logic an GUI classes when needed i.e. basically passing variables ...

Python features

Is there any article/paper on what features the Python language has to offer? Why should one go with Python instead of any other language? What are the strong and the weak points of Python? ...

ahow can I resolve Django Error: str' object has no attribute 'autoescape'?

Hi have tried to create a inclusion tag on Django but don't work and return str' object has no attribute 'autoescape' this is the code of custom tag: from django import template from quotes.models import Quotes register = template.Library() def show_quote(): quote = Quotes.objects.values('quote', 'author').get(id=0) ...

integrate / build 'weather radar' widget

I'm looking to integrate a 'weather radar' widget into a site I'm building. The only available resource I can find is: http://www.meteoonline.co.uk/gadgets/Europe/Netherlands/135 which basically delivers a flash mov in a iframe ! urrrgh! - and 'permission denied' of course with any javascript interaction on the iframe.. Can anyone s...

Is there a better way of making numpy.argmin() ignore NaN values

Hello Everybody, I want to get the index of the min value of a numpy array that contains NaNs and I want them ignored >>> a = array([ nan, 2.5, 3., nan, 4., 5.]) >>> a array([ NaN, 2.5, 3. , NaN, 4. , 5. ]) if I run argmin, it returns the index of the first NaN >>> a.argmin() 0 I substitute NaNs with Infs a...

Enterprise Platform in Python, Design Advice

I am starting the design of a somewhat large enterprise platform in Python, and was wondering if you guys can give me some advice as to how to organize the various components and which packages would help achieve the goals of scalability, maintainability, and reliability. The system is basically a service that collects data from variou...

Bit of python help

I've tried to get this to work, but it just freezes. It should display a pyramid, but all it does is.. halts. from graphics import * valid_colours = ['red', 'blue', 'yellow', 'green'] colour = ['', '', ''] while True: colour[0] = raw_input("Enter your first colour: ") colour[1] = raw_input("Enter your second colour: ") co...

change values in a list - python

I have this code: a=[['a','b','c'],['a','f','c'],['a','c','d']] for x in a: for y in x: if 'a' in x: x.replace('a','*')` but the result is: a=[['a','b','c'],['a','f','c'],['a','c','d']] and bot a=[['b','c'],['f','c'],['c','d']] What should I do so the changes will last? ...

Python print statement prints nothing with a carriage return

I'm trying to write a simple tool that reads files from disc, does some image processing, and returns the result of the algorithm. Since the program can sometimes take awhile, I like to have a progress bar so I know where it is in the program. And since I don't like to clutter up my command line and I'm on a Unix platform, I wanted to us...