python

How do I specify a range of unicode characters in a regular-expression in python?

I am trying to match a range of Unicode characters and I am wondering how to do it. I can match simple ranges like [a-zA-Z] but how do I specify a range of Unicode characters. I've tried [#xD8-#xF6] without any luck. Any ideas? ...

Python wxPython how to align 2 toolbars on same the row, one aligned left and one aligned right!?

Hello. I use wxPython to sketch up a user interface for the a python program. I need to put 2 toolbars on the same row. One toolbar is on the left while the other is on the right. I use BoxSizer to achieve this (by putting a stretchable space between 2 toolbars) However, the stretchable space produces a blank space between 2 toolbar...

how to bold csv data in excel???

I work on a python(django) project. I write csv code as follows, response = HttpResponse(mimetype='text/csv') response['Content-Disposition'] = 'attachment; filename=DueDateWiseSearch.csv' writer = csv.writer(response) writer.writerow(['Infant Name','Mother Name','Mother Address', 'Next Vaccine Dose','Due date','Coment...

Problem with Django using Apache2 (mod_wsgi), Occassionally is "unable to import from module" for no apparent reason

I have put my Django web site up to my web server and have it set up using apache2 and mod_wsgi.. everything works fine most of the time but occasionally it will just give the error that it can't import a module (usually from my views file). However, it's not an issue with that module as it usually works, for example, I will get the erro...

Retrieve header information from exe

Hellow every one. I was wondering whether it would be possible to write a python script that retrieves header information from an .exe file. I tried googling but didn't really find any results that were usable. Thanks. Sept ...

Unicode problems when using io.StringIO to mock a file

I am using an io.StringIO object to mock a file in a unit-test for a class. The problem is that this class seems expect all strings to be unicode by default, but the builtin str does not return unicode strings: >>> buffer = io.StringIO() >>> buffer.write(str((1, 2))) TypeError: can't write str to text stream But >>> buffer.write(str(...

Python group by

Hello Assume that I have a such set of pair datas where index 0 is the value and the index 1 is the type: input = [('11013331', 'KAT'), ('9085267', 'NOT'), ('5238761', 'ETH'), ('5349618', 'ETH'), ('11788544', 'NOT'), ('962142', 'ETH'), ('7795297', 'ETH'), ('7341464', 'ETH'), ('9843236', 'KAT'), ('5594916', 'ETH'), ('1550003', 'ETH')] ...

How to set defualt python library path

I'm using FreeBSD 7.2. I upgraded to Python 2.6. However when I run any python app, it is still using /usr/local/lib/pytho25 as the library path. How do I change it? I cannot modify the python app. Basically I need to change the default lib path to python26. ...

While running some java DB Unit tests which call a python script how can I test the code coverage for the python script?

I have a python script which generates some reports based on a DB. I am testing the script using java Db Units which call the python script. My question is how can I verify the code coverage for the python script while I am running the DB Units? ...

Type safety in Python

I've defined a Vector class which has three property variables: x, y and z. Coordinates have to be real numbers, but there's nothing to stop one from doing the following: >>> v = Vector(8, 7.3, -1) >>> v.x = "foo" >>> v.x "foo" I could implement "type safety" like this: import numbers class Vector: def __init__(self, x, y, z): ...

BulkLoader -export_transform

I have created web application using java.I wantted to download data from appengine datastroe so that I am using BulkLoader concept. In my project I designed entity as follows @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long school_id; @Basic private String schoolname; After that I tried to download data so th...

How can I start a python subprocess command on linux shell from within Django web app?

Hi, I have a web app which reads and displays log files generated by python test files. Currently I can launch the python files from cli and it works fine. However I would like to be able to launch python tests from within the application. At the minute I have a "Launch test" button which calls a function in the views.py file def lau...

Mapping result of psycopg2 into dataframe for R with RPY2

Hello Guys, With psycopg2, i get result of query in this form : [(15002325, 24, 20, 1393, -67333094L, 38, 4, 493.48763257822799, 493.63348372593703), (15002339, 76, 20, 1393, -67333094L, 91, 3, 499.95845909922201, 499.970048093743), (15002431, 24, 20, 1394, -67333094L, 38, 4, 493.493464900383, 493.63348372593703), (150024...

Django ORM with Postgres: rows unexpectedly deleted - Bug?

Hi, I have the problem that objects were unexpectedly deleted and created a minimal example. I dont't know whether it's a bug or if a made a thinking error. The models are something like that: class A(models.Model): related = models.ForeignKey('C', blank = True, null = True) class B(models.Model): title = models.CharField(max...

Why does adding a trailing comma after a string make it a tuple?

I want to know that why adding a trailing comma after a string makes it tuple. I.e. abc = 'mystring', print abc # ('mystring,) When I print abc it returns a tuple like ('mystring',). ...

Encoding calling from pyodbc to a MS SQL Server

I am connecting to a MS SQL server through SQL Alchemy, using pyodbc module. Everything appears to be working fine, until I began having problems with the encodings. Some of the non-ascii characters are being replaced with '?' The DB has a collation 'Latin1_General_CI_AS' (I've checked also the specific fields and they keep the same col...

Django on Google App Engine: debug queries to datastore

What is the best way to get something similar to django-debug-toolbar working on Google App Engine? At least I want to log all GQL at my local development environment. I am using django-nonrel + djangoappengine + djangotoolbox. I tried: debug-toolbar - does not work http://popcnt.org/2008/05/google-app-engine-tips.html - link to the c...

Is it possible to generate a Python function with arguments in runtime?

Say, I have a python function as following: def ooxx(**kwargs): doSomething() for something in cool: yield something I would like to provide another function with named arguments for hints as following: def asdf(arg1, arg2, arg3=1): frame = inspect.currentframe() args, _, _, values = inspect.getargvalues(fram...

What's Wrong With This HTTP/1.1 Request? Sometimes the Client Accepts it, and Sometimes it Rejects it.

I am in the process of writing a small HTTP/1.1 web server. I have threading turned off and am not currently using persistent connections. For normal requests where I specify the Content-Length and write the bytes out to the socket, everything works great. However, I need the ability to support chunked transfer encoding. When some of th...

Twitter Streaming API with oAuth with Python

Hello, I've been trying to search for a good Module to in order to use twitter live streaming API and Python. I have found "tweepy" but it seems like it is using the "Basic Authentication" which is now deprecated. Is there any new module out there to use for that purpose that use oAuth? Thanks, Joel ...