python

Uncompress Zlib string in using ByteArrays

Hi all, I have a web application developed in Adobe Flex 3 and Python 2.5 (deployed on Google App Engine). A RESTful web service has been created in Python and its results are currently in an XML format which is being read by Flex using the HttpService object. Now the main objective is to compress the XML so that there is as less a tim...

Installing TortoiseHG on Gnome in Ubuntu 9.10?

I followed the following steps to install TortoiseHG on Ubuntu 9.10 using the following document: http://bitbucket.org/tortoisehg/stable/wiki/nautilus I get the following error in my ~/.xsession-errors evolution-alarm-notify-Message: Tue Dec 1 23:28:26 2009 sys:1: GtkWarning: Refusing to add non-unique action 'HgNautilus::00None' ...

How to load compiled python modules from memory?

I need to read all modules (pre-compiled) from a zipfile (built by py2exe compressed) into memory and then load them all. I know this can be done by loading direct from the zipfile but I need to load them from memory. Any ideas? (I'm using python 2.5.2 on windows) TIA Steve ...

[Python] Does an entertaining guide exist?

I know of the few normally mentioned Python tutorial/guides/introductions, but I was wondering if there were any that were...more entertaining to go through, I guess. For example, Ruby has Why's (Poignant) Guide to Ruby, Haskell has Learn You a Haskell for Great Good, PHP even has this set of tutorials. Is there a Python equivelant? ...

Boost.Python: __init__ accepting None argument.

I have a C++ value type wrapped with Boost.Python which has a concept of a NULL value. The relevant parts of the wrapper code appear as follows: class_<TCurrency> currency( "TCurrency" ) .def( init<long>() ) .def( init<const std::string&>() ) <...>; Currently, trying to create a NULL instance in Python by passing None to ...

Pythonic List Comprehension

This seems like a common task, alter some elements of an array, but my solution didn't feel very pythonic. Is there a better way to build urls with list comprehension? links = re.findall(r"(?:https?://|www\.|https?://www\.)[\S]+", text) if len(links) == 0: return text urls = [] for link in links: if link[0:4] == "www.": ...

Bignum implementation that has efficient addition of small integers

I have been using python's native bignums for an algorithm and decided to try and speed it up by converting it to C++. When I used long longs, the C++ was about 100x faster than the python, but when I used GMP bindings in C++, it was only 10x faster than the python (for the same cases that fit in long longs). Is there a better bignum im...

Is there a tuple data structure in Python

I want to have an 3 item combination like tag, name, and list of values (array) what is the best possible data structure to store such things. Current I am using dictionary, but it only allows 2 items, but easy traversal using for k, v in dict.iteritems(): can we have something similar like: for k, v, x in tuple.iteritems(): ...

python Encoding Problem?

I read from source.sql ( sql script ) file INSERT INTO `Tbl_abc` VALUES (1111, 2222, 'CLEMENT', 'taya', 'MME', 'Gérant', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 4688, 0, NULL, NULL, 'MAILLOT 01/02/09', 'MAILLOT 01/04/09', NULL, NULL); And write to dest.sql With my list formated I met the problem with encoding for example: Gérant= ...

Python time comparison

How do I compare times in python? I see that date comparisons can be done and there's also "timedelta", but I'm struggling to find out how to check if the current time (from datetime.now()) is earlier, the same, or later than a specified time (e.g. 8am) regardless of the date. ...

Why _mysql.co that compiled on one Mac doesn't work on another?

Hi guys, I want to use Python-MySQLDB library on Mac so I have compiled the source code to get the _mysql.so under Mac10.5 with my Intel iMac (i386) This _mysql.co works in 2 of my iMacs and another Macbook. But that's it, it doesn't work in any other Macs. Does this mean some machine specific info got compiled into the file? ...

Getting data from the database with python(on Django framework)

Hello, ordinarily if I were writing a sql statement to this I would do something like this, SELECT * FROM (django_baseaccount LEFT JOIN django_account ON django_baseaccount.user_id = django_account.baseaccount_ptr_id) LEFT JOIN django_address ON django_account.baseaccount_ptr_id = django_address.user_id;name how do I put this into...

python video library

hello , Im working on a software that needs to do some video functions like converting video to sequence of images and then convert images ( after modifying )back to video what are the recommended libraries for this tasks plus ... what are the recommended library for PAINTING over video thank u very much ...

Looking for advice on how to develop applets for Gnome / Ubuntu

I am a linux (mostly ubuntu) user with a reasonable understanding of how the system works (although I am certainly not a linux guru!). In the past I have developed small cross-platform desktop applications in python/GTK and I delivered them to clients as self-contained filetrees, so that the only dependencies were Python itself and GTK. ...

Python SOAP client library using a HTTPS connection with keys

I want to query a SOAP service that requires the use of keys. I could write a SOAP client myself making use of httplib's HTTPSConnection, I'm pretty sure that would work, but it means I have to write a load of XML. Is there a nicer way to do this? Perhaps getting an existing SOAP library to use a HTTPSConnection object. I found an exam...

Is close() necessary when using iterator on a Python file object

Is it bad practice to do the following and not explicitly handle a file object and call its close() method? for line in open('hello.txt'): print line NB - this is for versions of Python that do not yet have the with statement. I ask as the Python documentation seems to recommend this :- f = open("hello.txt") try: for line in...

What algorithm to use to solve this simple mathematical problem efficiently?

I am puzzled with the following simple problem: Given positive integers b, c, m where (b < m) is True it is to find a positive integer e such that (b**e % m == c) is True where ** is exponentiation (e.g. in Ruby, Python or ^ in some other languages) and % is modulo operation. What is the most effective algorithm (with the lowest big-...

How to refer to the local module in Python?

Let's say we have a module m: var = None def get_var(): return var def set_var(v): var = v This will not work as expected, because set_var() will not store v in the module-wide var. It will create a local variable var instead. So I need a way of referring the module m from within set_var(), which itself is a member of modul...

Xcode gcc exit status 1

first of all i am very new to all this. i recently upgraded to Snow Leopard and installed the Xcode + iPhone dev package, 3.1.2. I went on to install the Django framework + MYSQLDB handler. During the build stage, the terminal shows me the gcc exit status 1 error. But I have the Xcode already installed? where am I going wrong? Also whi...

Python regex matching Unicode properties

Perl and some other current regex engines support Unicode properties, such as the category, in a regex. E.g. in Perl you can use \p{Ll} to match an arbitrary lower-case letter, or p{Zs} for any space separator. I don't see support for this in either the 2.x nor 3.x lines of Python (with due regrets). Is anybody aware of a good strategy t...