python

is someone achieve online file compare

I want to a visualize web file compare tool,that can embed into my app,I know there some software like beyond compare,it has done great job,but it on windows & need buy licence,if someone has develop a web version,then it can cross platform, does some already achieve this? if it is python - friendly is great appreciated ...

Best way to iterate through all rows in a DB-table

I often write little Python scripts to iterate through all rows of a DB-table. For example sending all to all subscribers a email. I do it like this conn = MySQLdb.connect(host = hst, user = usr, passwd = pw, db = db) cursor = conn.cursor() subscribers = cursor.execute("SELECT * FROM tbl_subscriber;") for subscriber in subscribers: ...

python backports for some methods

Is there any backport for the following methods to work with python 2.4: any, all, collections.defaultdict, collections.deque ...

How do I find out in which file or module is my function called?

Python 2.5 to 2.7: #a.py: def foo(): pass #b.py from a import foo foo() From foo(), I'd like to know that it has benn called in the "b" module. The only way I can think of right now is raising an exception, catching it and inspecting the traceback (going one level up). Is there a mare natural way of doing this? ...

Prepopulating a Django FileField

Hey all I wanted to know how is it possible in django to bind an already uploaded file (stored in the file system of server) to a Model FileField. This way I want to have my edit page of that model to prepopulate the FileField with this file. Thanks ...

Good python XML parser to work with namespace heavy documents

Python elementTree seems unusable with namespaces. What are my alternatives? BeautifulSoup is pretty rubbish with namespaces too. I don't want to strip them out. Examples of how a particular python library gets namespaced elements and their collections are all +1. Edit: Could you provide code to deal with this real world use-case using...

Linux / Bash using PS -f for specific PID returns in different format than PS -f, also queston about using Grep to parse this

I have a need, for a python script I'm creating, to first get just the PID of a process (based on its name) and then to get from that process, usings its PID, its time duration, which, from the printout below, would be "00:00:00" root 5686 1 0 Sep23 ? 00:00:00 process-name I am using this to get just the PID, by the p...

Designing a scalable product database on Google App Engine

I've built a product database that is divided in 3 parts. And each part has a "sub" part containing labels. But the more I work with it the more unstable it feels. And each addition I make it takes more and more code to get it to work. A product is built of parts, and each part is of a type. Each product, part and type has a label. And...

simple python lxml CRUD ?

I have been looking for a while a python module/API that does something I believe is quite simple: Read an XML file Add/Edit/Remove entries So far I've found several snippets that interface with complicated object oriented databases, but nothing dead simple as: xml = etree.parse ('file.xml') xml.add(xpath, new_node(attrs)) xml.remo...

Focus-follows-mouse in wxPython?

I'm developing an application that contains a number of panes. See the screenshot: The left settings pane is a wx.ScrolledPanel that contains a number of wx.Panels. The top events pane is a wx.grid.Grid. The bottom data pane is a wx.Panel that contains a wx.grid.Grid. The middle plot pane is a wx.Panel containing an enthought chaco p...

SQLite error when loading two python scripts simultaneously

I have two python scripts that have to run simultaneously because they interact with each other. One script is a 'server' script running locally and the other is client script that connects to it via a socket. Normally I just open a couple terminal tabs and run the server script in one and the client in the other. After starting and stop...

Change working directory in shell with a python script

I want to implement a userland command that will take one of its arguments (path) and change the directory to that dir. After the program completion I would like the shell to be in that directory. So I want to implement cd command, but with external program. Can it be done in a python script or I have to write bash wrapper? Example: ...

Dynamic base class and factories

I have following code: class EntityBase (object) : __entity__ = None def __init__ (self) : pass def entity (name) : class Entity (EntityBase) : __entity__ = name def __init__ (self) : pass return Entity class Smth (entity ("SMTH")) : def __init__ (self, a, b) : self.a...

What is a "method" in Python?

can anyone, please, explain to me in very simple terms what "method" is in Python? The thing is in many Python tutorials for beginners this word is used in such way as if the beginner already knew what method is in the context of Python. While I am of course familiar with the general meaning of this word, I have no clue what this term m...

Determine Declaring Order of Python/IronPython Functions

I'm trying to take a python class (in IronPython), apply it to some data and display it in a grid. The results of the functions become columns on the grid, and I would like the order of the functions to be the order of the columns. Is there a way to determine the order of python functions of a class in the order they were declared in t...

Python GUI for portable app

I am developing a python app, using python and sqlite and GUI to re-create a Access 2007 report generating app. Since the app is portable, I'm looking for GUI solution for python that user doesn't need to install addition things before using the app. Is there any GUI solution suits my need? Thanks! ...

Django Models (1054, "Unknown column in 'field list'")

No idea why this error is popping up. Here are the models I created - from django.db import models from django.contrib.auth.models import User class Shows(models.Model): showid= models.CharField(max_length=10, unique=True, db_index=True) name = models.CharField(max_length=256, db_index=True) aka = models.CharField(max_le...

Python: Is there any reason *not* to cache an object's hash?

I've written a class whose .__hash__() implementation takes a long time to execute. I've been thinking to cache its hash, and store it in a variable like ._hash so the .__hash__() method would simply return ._hash. (Which will be computed either at the end of the .__init__() or the first time .__hash__() is called.) My reasoning was: "T...

Python comparison functions

I have some data that lends itself to representation as a value and a comparison function, (val, f), so another value can be checked against it by seeing if f(val, another) is True. That's easy. Some of them just need >, <, or == as f, however, and I can't find a clean way of using them; I end up writing things like ScorePoint(60, la...

Problem with using Win32 IPHelper API in python

I'm attempting to create python module for getting network parameters. I'm using ctypes and has some problems. Function __getInterfaces_win2k() works with python 2.5 and 2.6, but doesn't work with python 2.7 (Unhandled exception at 0x1e001759 in python.exe: 0xC0000005: Access violation reading location 0x00000010.) Function __getInterf...