python

How to stay under GAE quotas? Algorithm design

Hi there I have a function in my app that uses a lot of resources, and takes time to execute. This is normal and control, however I often get errors due to GAE limit of 30 secs/request. My function takes the argument and returns several results one after the other, decreasing the size of the argument (a unicode string) Summary: def m...

How to order by ancestor/parent Google App Engine query?

I would like to order entities by ancestor, GQL reference only mentions properties in ordering. Do I have to store a parent as a property to involve it in the ordering? I trying to achieve something like this: Foo.all().ancestor(bar).order('ancestor').order('-value').fetch(100) EDIT: I have something like this: bar ├ spam │ ├ fo...

Installing python modules in GNU/Linux

installing python modules in GNU/Linux. Are there any good PDFs on installing modules? I would like to install some of these Python: 50 modules for all needs. I tried PIL http://effbot.org/downloads/Imaging-1.1.7.tar.gz but it did not work. PS: what does community wiki mean? ...

Get ip address of visitors using Python (specifically Flask micro-framework)

Hi, I am using the Flask micro-framework (based on Werkzeug) which uses Python (2.6 in my case). I'm making a website where users can log on and download files. I need to get the ip address of users when they log on (for logging purposes). Does anyone know how to do this? Surely there is a way to do it with Python? I apologize for t...

allow_none in twisted XML-RPC server

I am building xml rpc service using twisted and I would like to use None just as it can be done in standard python lib. How can I pass allow_none to the twisted version of xmlrpc server? EDIT In [28]: sock = rpc.ServerProxy('http://localhost:7080',allow_none=True) In [29]: sock Out[29]: <ServerProxy for localhost:7080/RPC2> In [30]: ...

python string pattern matching

new_str="@@2@@*##1" new_str1="@@3@@*##5##7" How to split the above string in python for val in new_str.split("@@*"): logging.debug("=======") logging.debug(val[2:]) // will give for st in val.split("@@*"): //how to get the values after ## in new_str and new...

Checking Version of Python Interpreter Upon Execution of Script With Invalid Syntax

I have a Python script that uses Python version 2.6 syntax (Except error as value:) which version 2.5 complains about. So in my script I have included some code to check for the Python interpreter version before proceeding so that the user doesn't get hit with a nasty error, however, no matter where I place that code, it doesn't work. On...

Java oneliner for list cleanup

Is there a construct in java that does something like this(here implemented in python): [] = [item for item in oldList if item.getInt() > 5] Today I'm using something like: ItemType newList = new ArrayList(); for( ItemType item : oldList ) { if( item.getInt > 5) { newList.add(item); } } And to me the first way looks a ...

What is the equivalent of "require" (Ruby) in Python?

I am coming to python from ruby. What is the equivalent statement of require (Ruby) in Python? ...

forms.ModelChoiceField and Internationalization

Does anybody know, how to support i18n in forms ? I would like to use {% trans "SOMETHING" %} in a template. Or should I just use _() in views.py only for the selectbox, in order to translate these strings? I do not want to use model i18n addons. ...

Converting domain names to idn in python

I have a long list of domain names which I need to generate some reports on. The list contains some IDN domains, and although I know how to convert them in python on the command line: >>> domain = u"pfarmerü.com" >>> domain u'pfarmer\xfc.com' >>> domain.encode("idna") 'xn--pfarmer-t2a.com' >>> I'm struggling to get it to work with a ...

What are the WordPress analogs\clones that would run under Google App Engine?

So I want it to run on free google app engine version, I want it to be more or less structured like WP (meaning end user experience). I need clean readable source so I could change it as I wish. If there are no such alike WP ones than some other Blog Engine would work for me. What are the WordPress analogs\clones that would run under ...

Problem Accessing WSDL-Service with python suds raises TypeNotFound: ArrayOfint

Type not found: '(ArrayOfint, http://schemas.microsoft.com/2003/10/Serialization/Arrays, )' is what suds resolver raises. In ...2003/10/Serialization/Arrays ArrayOfInt is defined, so I guess linux' case sensitivity is the problem. Any Idea how I can get around that? from suds.client import Client c = Client("https://developer-api.aff...

How to Compare 2 very large matrices using Python

I have an interesting problem. I have a very large (larger than 300MB, more than 10,000,000 lines/rows in the file) CSV file with time series data points inside. Every month I get a new CSV file that is almost the same as the previous file, except for a few new lines have been added and/or removed and perhaps a couple of lines have been...

How's Python GUI development today (Sep/2010)?

Last time I saw, GUIs in Python were extremely ugly, how's it today? (saw some beautiful images on google images, but I don't know if are really Python's) ...

How to generate a random partition from an iterator in Python

Given the desired number of partitions, the partitions should be nearly equal in size. This question handles the problem for a list. They do not have the random property, but that is easily added. My problem is, that I have an iterator as input, so shuffle does not apply. The reason for that is that I want to randomly partition the nodes...

Is there a way to run a python script that is inside a zip file from bash?

I know there is a way to import modules which are in a zip file with python. I created kind of custom python package library in a zip file. I would like to put as well my "task" script in this package, those are using the library. Then, with bash, I would like to call the desired script in the zip file without extracting the zip. The ...

Using genfromtxt to import csv data with missing values in numpy

Hi, I have a csv file that looks something like this (actual file has many more columns and rows): 1,2,3,4,5 6,7,8,9,10 11,12,13,14,15 16 Say the name of the file is info.csv If I try to import this using data = numpy.genfromtxt('info.csv', delimiter = ',') then I get the following error: ValueError: Some errors were detected ! ...

Finding maximum value in a dictionary containing mixed items in Python

I have a dictionary with either a integer or a tuple of integers as value. How do I find the maximum integer present in dicts' values? Example: x1 = {0:2, 2:1, 3:(1, 2), 20:3} should return 3 and x2 = {0:2, 2:1, 3:(1, 5), 20:3} should return 5 ...

boost::python: Python list to std::vector

Finally I'm able to use std::vector in python using the [] operator. The trick is to simple provide a container in the boost C++ wrapper which handles the internal vector stuff: #include <boost/python.hpp> #include <vector> class world { std::vector<double> myvec; void add(double n) { this->myvec.push_back(n); }...