python

Can I remove leading zeros in a url in django ?

Am redirecting urls from a legacy site, which gets me to a url like this: http://example.com/blog/01/detail I would like to automatically remove the leading zeros from these urls (seems it doesn't matter how many zeros are in there 001 0001 000001 work) so that the page redirects to: http://example.com/blog/1/detail Is there a simple...

how to update a Django page without a page reload ?

My Django app displays data from a database. This data changes without user intervention, i.e. behind the scenes. Whenever it changes, I would like the webpage to update the changed sections without a full page reload. Obviously AJAX springs to mind. When the page is loaded initially (or manually, fully re-loaded later on), the rendered...

Django-based skill implementation

I'm working on a RPG using django and am considering different options for implementing part of the skill system. Say I have a base skill class ie, something like: class Skill (models.Model): name = models.CharField() cost = models.PositiveIntegerField() blah blah blah What would be some approaches to implementing s...

Render wikitext with Python

I need to render wikitext (pulled from the database of a mediawiki of it's relevant) and display in some other format (ultimately to be rendered as a PDF, but basically any other format will do). I can definately hack together something that does the job but ultimately I'll be writing it as I go along, and I can see that the overhead of...

Passing numpy.arange() an argument.

I'm trying to pass the values that I want numpy.arange to use. The code is: for x in numpy.arange(argument) where argument is: argument = (.1,6.3,.1) (tuple) TypeError: arange: scaler arguements expected instead of a tuple arguement = [.1,6.3,.1] (list) TypeError: unsupported operand type(s) for -: 'str' and 'int' arguement = '...

Automate interaction with a webpage in python

I want to automate interaction with a webpage. I've been using pycurl up til now but eventually the webpage will use javascript so I'm looking for alternatives . A typical interaction is "open the page, search for some text, click on a link (which opens a form), fill out the form and submit". We're deploying on Google App engine, if tha...

Does pytables support NULL ?

I have table looks like this ------------------ GeneId | ProteinId 1 | 157 2 | - 3 | 587 4 | 897 5 | - 6 | 120 In realational database, I can treat ProteinId column as INT and use NULL for "-" data. However, I can't find the same option in pytables. Does pytables support NULL...

Are there any pure Python, BSD-ish open source SVG libraries?

I'm looking for a pure Python library to help put together SVG images. It doesn't need to be fast. I know pySVG exists, but I'm not interested in a GPL library (and I can't use GPL libraries for this particular project). Basic SVG elements aren't especially complicated, so I suppose I could roll my own, but I'd rather participate in a...

How to get restructuredText to add a class to every html <p> tag?

Hey all, I'm using Django's markup package to transform restructuredText into html. Is there a way to customize the HTML writer to add a class attribute to each <p> tag? I could use the class directive for each paragraph, but I'd like to automate this process. For example, I want this restructured text: hello ===== A paragraph of t...

Pulling HTML from a Webpage in Java

I want to pull the entire HTML source code file from a website in Java (or Python or PHP if it is easier in those languages to display). I wish only to view the HTML and scan through it with a few methods- not edit or manipulate it in any way, and I really wish that I do not write it to a new file unless there is no other way. Are there ...

Python2.6 Backtrack/Ubuntu wxPython

I wrote a python app and it needs python2.6. I'm trying to get it to run in Backtrack 4 which is a pen-testing linux distro based on debian/ubuntu. I'v managed to install python2.6 along side of python2.5. Now I'm trying to install wxPython for 2.6 from the repos but I can't get it to install it for python2.6 rather than 2.5. Is there so...

Converting UTF-8(or other 8-bit encoding) to 7 or fewer bits.

I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB. How would I go about doing thi...

Using the Python shell in Vi mode on WIndows

I know that you can use the Python shell in Vi mode on Unix-like operating systems. For example, I have this line in my ~/.inputrc: set editing-mode vi This lets me use Vi-style editing inside the Python shell. But can this be made to work when using Python on a Windows XP box? I'm using the pre-built Python for Windows downloaded di...

Invalid Token when using Octal numbers.

Hi, I'm a beginner in python and I'm trying to use a octal number in my script, but when I try it, it returns me that error: >>> a = 010 SyntaxError: invalid token (<pyshell#0>, line 1) >>> 01 SyntaxError: invalid token (<pyshell#1>, line 1) There's something wrong with my code? I'm using Python3 (and reading a python 2.2 book) ...

Programatically updating a spreadsheet hosted on google docs

I've got a pre-existing spreadsheet hosted on google docs. Each month I update this document. I've got a template workseet in the spreadseet that I'd like to clone and then update. I'd prefer to clone the worksheet rather than create it from scratch as it has some pretty complex formulas. I'm using the Python api for the google docs ...

How to get the URL Image which is displyed by script

When I view the source of page, I do not find the image src. but the image is displayed on the page. This image is generated by some server side code. I am using the selenium for testing. I want to download this image for verification/comparison. How to get that image using python? ...

What is internal representation of string in Python 3.x

In Python 3.x, a string consists of items of Unicode ordinal. (See the quotation from the language reference below.) What is the internal representation of Unicode string? Is it UTF-16? The items of a string object are Unicode code units. A Unicode code unit is represented by a string object of one item and can hold either a ...

Get new dict from old dict with condition?

I am an dictionary (Dictionary of dictionary) old_dict = { '1':{'A':1, 'check': 0, 'AA':2, 'AAA':3 , 'status':0}, '2':{'A':11,'check': 0, 'AA':22, 'AAA':33 ,'status':1}, '3':{'A':111,'check': 0, 'AA':222, 'AAA':333 ,'status':0}, '4':{'A':1111,'check': 1, 'AA':2222, 'AAA':3333 ,'status':0}, } I Want to get a new...

Html Agility Pack for python

Is there any module for python similar to Html Agility Pack? If not, can anyone recommend me an alternative. Thanks in advance! ...

Python Spliting a string

Hello, I looking to split a string up with python, I have read the documentation but don't fully understand how to do it, I understand that I need to have some kind of identifier in the string so that the functions can find where the string(unless I can target the first space in the sentence?) So for example how would I split "Sico87 ...