python

python (jython) archiving library.

Is there a neat archiving library that automatically handles archiving a folder or directories for you out there? I am using Jython, so Java libs are also open for use. -UPDATE- Also Im looking for timestamp archiving. ie archive-dir/2008/11/16/zipfilebypreference.zip then the next day call it again and it creates another folder. Im s...

How to make the keywords recognizable in simpleparse?

I've been trying to create a parser using simpleparse. I've defined the grammar like this: <w> := [ \n]* statement_list := statement,(w,statement)? statement := "MOVE",w,word,w,"TO",w,(word,w)+ word := [A-Za-z],[A-Za-z0-9]*,([-]+,[A-Za-z0-9]+)* Now if I try to parse a string MOVE ABC-DEF TO ABC MOVE DDD TO XXX The second statement ...

Optimization of Google App Engine Code

Google app engine tells me to optimize this code. Anybody any ideas what I could do? def index(request): user = users.get_current_user() return base.views.render('XXX.html', dict(profiles=Profile.gql("").fetch(limit=100), user=user)) And later in the template I do: {% for profile in profiles %} <a href="/p...

Looping in Django forms

Hi, I've just started building a prototype application in Django. I started out by working through the Django app tutorial on the Django site which was pretty helpful, and gave me what I needed to get started. Now I have a couple of what I hope are very simple questions: I want to put a loop into views.py, looping over a set of variabl...

What is a good reference guide for Django

Hi, I've just started using Django, and have never programmed in Python before. I really feel the need for a Django / Python reference guide, either online or in book form. Anyone know of a good one? I'm really looking for a reference guide, rather than a "how-to" guide, as the latter seem to be easy enough to find. Thanks, Ben ...

DJANGO Template Variables and Javascript

Hello, When i render a page using the Django template renderer, i can pass in a dictionary variable containing various values so i can manipulate them in the page using {{ myVar }}. Is there a way to access the same variable in Javascript (perhaps using the DOM, i don't know how Django makes the variables accessible), i want to be able...

Form (or Formset?) to handle multiple table rows in Django

Hi, I'm working on my first Django application. In short, what it needs to do is to display a list of film titles, and allow users to give a rating (out of 10) to each film. I've been able to use the {{ form }} and {{ formset }} syntax in a template to produce a form which lets you rate one film at a time, which corresponds to one row i...

Python xml.dom.minidom.parse() function ignores DTDs

I have the following Python code: import xml.dom.minidom import xml.parsers.expat try: domTree = ml.dom.minidom.parse(myXMLFileName) except xml.parsers.expat.ExpatError, e: return e.args[0] which I am using to parse an XML file. Although it quite happily spots simple XML errors like mismatched tags, it completely ignores th...

Python Distutils

I was unable to install cython due to strict version numbering class of Distutils. For example binutils-2.18.50-20080109-2.tar.gz cannot be used along with MinGW for installing cython. The source code documentation says that "The rationale for this version numbering system will be explained in the distutils documentation." I am unable to...

How can I get my python (version 2.5) script to run a jar file inside a folder instead of from command line??

I am familiar with using the os.system to run from the command line. However, I would like to be able to run a jar file from inside of a specific folder, eg. my 'test' folder. This is because my jar (located in my 'test' folder) requires a file inside of my 'test' folder. So, how would I write a function in my script that does the follow...

How do I change directory back to my original working directory with Python?

I have a function that resembles the one below. I'm not sure how to use the os module to get back to my original working directory at the conclusion of the jar's execution. def run(): owd = os.getcwd() #first change dir to build_dir path os.chdir(testDir) #run jar from test directory os.system(cmd) #change dir ...

Validating with an XML schema in Python

I have an XML file and an XML schema in another file and I'd like to validate that my XML file adheres to the schema. How do I do this in Python? I'd prefer something using the standard library, but I can install a third-party package if necessary. ...

What is the best way to debug my Python code?

I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this? ...

Calling Java (or python or perl) from a PHP script

Hi, I've been trying to build a simple prototype application in Django, and am reaching the point of giving up, sadly, as it's just too complicated (I know it would be worth it in the long-run, but I really just don't have enough time available -- I need something up and running in a few days). So, I'm now thinking of going with PHP ins...

Is it possible to bind an event against a menu instead of a menu item in wxPython?

Nothing to add ...

Why is fuse not using the class supplied in file_class

I have a python fuse project based on the Xmp example in the fuse documentation. I have included a small piece of the code to show how this works. For some reason get_file does get called and the class gets created, but instead of fuse calling .read() on the class from get_file (file_class) fuse keeps calling Dstorage.read() which defeat...

How to unquote a urlencoded unicode string in python?

I have a unicode string like "Tanım" which is encoded as "Tan%u0131m" somehow. How can i convert this encoded string back to original unicode. Apparently urllib.unquote does not support unicode. ...

Python - String Literals

I have a string that contains both double-quotes and backslashes that I want to set to a variable in Python. However, whenever I try to set it, the quotes or slashes are either removed or escaped. Here's an example: >>> foo = 'baz "\"' >>> foo 'baz ""' So instead of baz "\" like I want I'm getting baz "". If I then try to escape the b...

Dynamic module import in Python

I'm writing a Python application that takes as a command as an argument, for example: $ python myapp.py command1 I want the application to be extensible, that is, to be able to add new modules that implement new commands without having to change the main application source. The tree looks something like: myapp/ __init__.py co...

loadComponentFromURL falls over and dies, howto do CPR?

hi guys Well I testing my jython program, that does some neat [".xls", ".doc", ".rtf", ".tif", ".tiff", ".pdf" files] -> pdf (intermediary file) -> tif (final output) conversion using Open Office. We moved away from MS Office due to the problems we had with automation. Now it seems we have knocked down many bottles related to show sto...