python

Django apps equivalent to Drupal's CCK and Views modules?

Are there any Django apps equivalent to Drupal's Views and CCK modules? I find Django much more flexible and logically organized than Drupal. But I think Drupal's Views and CCK modules are killer apps. They let the webmaster very rapidly to build new data models and queries through GUI without touching the code. These modules are very u...

How can I convert an excel spreadsheet (.xls) to a shapefile programmatically?

I have an excel spreadsheet I want to convert to an ESRI shapefile programmatically. It contains X and Y coordinates in two columns, as well as a variety of attribute data in other columns. The spreadsheet is in excel 97 format (i.e. not .xlsx). I would like to be able to convert this to a point geometry shapefile, with each row's x,y...

Print output in a single line

Hello! I have the following code: >>> x = 0 >>> y = 3 >>> while x < y: ... print '{0} / {1}, '.format(x+1, y) ... x += 1 Output: 1 / 3, 2 / 3, 3 / 3, I want my output like: 1 / 3, 2 / 3, 3 / 3 I searched and found that the way to do this in a single line would be: sys.stdout.write('{0} / {1}, '.format(x+1, y)) Is...

How do I create a data structure that will be serialized this JSON format in python?

I have a function that accepts a list of date objects and should output the following dictionary in JSON: { "2010":{ "1":{ "id":1, "title":"foo", "postContent":"bar" }, "7":{ "id":2, "title":"foo again", "postContent":"bar baz boo" } }, "2009":{...

Help with urllib + proxy in Python

Hey ppl... My program isn't running properly as should be... I'm getting only the error message (except part) of the urlopen with the proxy... why? At least, one of the proxy was tested and work correctly... please, some one take a look on the code here: http://pastebin.com/cBfv5H8J edit: the code doesn't work on the first try part,...

Getting an external list of ip and turning in to variable dic in Python

How can I do this: Enter on this website (http://www.samair.ru/proxy/time-01.htm) and get the list of the ip address and turn it to a dictionary variable? whit these code in particular, I only can get the first ip of the website ip = urllib.urlopen('http://www.samair.ru/proxy/time-01.htm').read() clientIp = re.search("(\d+\.\d+\.\d+\....

How can I alter a file and write only the changes to disk - basically, sed (python)?

Let's say I have a file /etc/conf1 it's contents are along the lines of option = banana name = monkey operation = eat and let's say I want to replace "monkey" with "ostrich". How can I do that without reading the file to memory, altering it and then just writing it all back? Basically, how can I modify the file "in place"? ...

How to use python build script with teamcity CI?

I am currently researching using the TeamCity CI software for our comapanies CI automation needs but have had trouble finding information about using different build scripts with TeamCity. We have C++ projects that need to have build/test automation and we currently have licenses for TeamCity. I have looked into using scons for the build...

Changing property names in Google application engine.

Hi All, Is there any way to alter the Property names in the Google application engine for a Kind, or in other words is there a way to alter the column names of a table in Google application Engine (though it follows a different way to handle the data)? I am using python. Please suggest. Thanks in advance. ...

Django Python Delete Project App Library

If I want to delete a Django App or Project. Is there a way to cleanly delete it? Or a library in Python? How can I delete and re install libraries. So I am SURE that nothing is left of that library. Thanks a lot ...

List classes in directory (Python)

I'm developing a Python 2.6 package in which I would like to fetch a list of all classes in a certain directory (within the package) in order to then perform introspection on the class objects. Specifically, if the directory containing the currently executing module has a sub-dir called 'foobar' and 'foobar' contains .py files specifyin...

Byte to String Python 3 Websockets

Hey. I'm converting a 2.6.5 application to python 3.1. I'm trying to convert a byte order received through socket.recv() into a string, by doing the following: str(temp, 'UTF-8', 'ignore') The problem is unknown characters are removed ("ignored"), such as \x00 and \xff (WebSockets characters), I do want to convert the byte order to a ...

Create a structure in a flat xml file

Hello all, I have an xml file made like this: <car>Ferrari</car> <color>red</color> <speed>300</speed> <car>Porsche</car> <color>black</color> <speed>310</speed> I need to have it in this form: <car name="Ferrari"> <color>red</color> <speed>300</speed> </car> <car name="Porsche"> <color>black</color> <speed>310</speed...

Convert XML to python objects using lxml

I'm trying to use the lxml library to parse an XML file...what I want is to use XML as the datasource, but still maintain the normal Django-way of interactive with the resulting objects...from the docs, I can see that lxml.objectify is what I'm suppossed to use, but I don't know how to proceed after: list = objectify.parse('myfile.xml') ...

Multiple application entry points

Hi, Recently I was trying to add unit tests to an existing binary by creating a extra (DLLMain) entry point to an application that already has a main entry point (it is a console exe). The application seemed to compile correctly although I was unable to use it as a DLL from my python unit test framework, all attempts to use the exe as a...

Python: Select subset from list based on index set

I have several lists having all the same number of entries (each specifying an object property): property_a = [545., 656., 5.4, 33.] property_b = [ 1.2, 1.3, 2.3, 0.3] ... and list with flags of the same length good_objects = [True, False, False, True] (which could easily be substituted with an equivalent index list: good_indices...

how to use session without having to pass it [SqlAlchemy]

I want to check diferent values in the DB and create a new value, so i need to query and i don't know if i have to create a session in my SQLAlchemy class or how do i have to do it? using session like a global?, i didn't find in documentation. Somethin like this: class MyClass(Base): __tablename__ = 'my_class' __table_args__ =...

How to detect source code in a text?

Is it possible to detect a programming language source code (primarily Java and C# ) in a text? For example I want to know whether there is any source code part in this text. .. text text text text text text text text text text text text text text text text text text text text text text text text text text text public static Person c...

Python: **kargs instead of overloading?

Hi, I have a conceptual Python design dilemma. Say I have a City class, which represents a city in the database. The City object can be initialized in two ways: An integer (actually, an ID of an existing city in a database) A list of properties (name, country, population, ...), which will generate a new city in the database, and re...

making paint in pyqt or qt

hello i have just received a task to implement a software that paints over pictures (pretty much like microsoft paint ) i have no idea where to start or how to do that. do anyone have a good reference or idea for painting in qt or pyqt ? this will be highly appreciated thanks in advance ...