python

wxPython change field on tab

I apologize for a simple question, but I did not see this in the tutorials. I have a very simple gui, but I would like the user to be able to press the TAB key and have it move from one input field to another. I am using wxPython with Python 2.6. ...

Compatibility with IIS and Apache -- PHP, Python, etc?

I'm currently planning out a web app that I want to host for people and allow them to host themselves on either Linux/Apache of IIS6 or IIS7 (for the benefits of bandwidth, directory services [login, etc.]). I see that PHP is supported on both platforms. I've heard people serving Django and Python in IIS using PyISAPIe. I'm not sure ab...

How to find elements by 'id' field in SVG file using Python

Below is an excerpt from an .svg file (which is xml): <text xml:space="preserve" style="font-size:14.19380379px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu Sa...

Google App Engine with Eclipse?

I'm trying to use Google App Engine with Eclipse but it's not working. I downloaded PyDev, and made a Hello World Python app, so that's working fine. Then I created a new project, with the "Google App Engine" template. I was following these instructions. I used the "Hello Webapp World" as a template, and didn't change any of the Python...

Correctness about variable scope

Hi all, I'm currently developing some things in Python and I have a question about variables scope. This is the code: a = None anything = False if anything: a = 1 else: a = 2 print a # prints 2 If I remove the first line (a = None) the code still works as before. However in this case I'd be declaring the variable inside an "...

Dealing with UTF-8 numbers in Python

Hi, I have read many similar questions, apologies if this is considered a duplicate. Suppose I am reading a file containing 3 comma separated numbers. The file was saved with with an unknown encoding, so far I am dealing with ANSI and UTF-8. If the file was in UTF-8 and it had 1 row with values 115,113,12 then: with open(file) as f: ...

Bash while loop calling a Python script

I would like to call a Python script from within a Bash while loop. However, I do not understand very well how to use appropriately the while loop (and maybe variable) syntax of the Bash. The behaviour I am looking for is that, while a file still contains lines (DNA sequences), I am calling a Python script to extract groups of sequences ...

Pure Python in Xcode?

Could anyone tell me how to use pure Python without Cocoa support in Xcode? I can only find the Cocoa-Python template on the Internet. Thanks in advance. ...

how to read an excel file on google app engine

Generally I work with CSV files but for this project I need to support XLS too. Does anyone have experience reading XLS files on GAE with Python? 2 possible alternatives I am considering: xlrd Google Docs API ...

Python directory list returned to Django template

Total Python newb here. I have a images directory and I need to return the names and urls of those files to a django template that I can loop through for links. I know it will be the server path, but I can modify it via JS. I've tried os.walk, but I keep getting empty results. ...

Vim automatically removes indentation on Python comments

I'm using Vim and editing Python scripts. Autoindent works pretty well in general, but when I start a new line and type '#' to type a comment, Vim unindents that line for me. For example, if have def foo(): and I press enter, Vim will indent properly def foo(): pass but, if instead of typing pass, I type '#', it unindents au...

Concurrent downloads - Python

Hi folks, the plan is this: I download a webpage, collect a list of images parsed in the DOM and then download these. After this I would iterate through the images in order to evaluate which image is best suited to represent the webpage. Problem is that images are downloaded 1 by 1 and this can take quite some time. It would be gre...

Python: Misunderstanding about how imports work

Here is my loader class, ItemLoader.py: from google.appengine.ext import db from google.appengine.tools import bulkloader import models class ItemLoader(bulkloader.Loader): def __init__(self): bulkloader.Loader.__init__(self, 'Item', [('CSIN', int), # not too DRY... ('name',...

Python and Memory Consumption

Hey, I am searching for a way to be able to handle overloading the RAM and CPU using a high memory program... I would like to process a LARGE amount of data contained in files. I then read the files and process the data therein. The problem is there are many nested for loops and a root XML file is being created from all the data proces...

How do I unescape HTML entities in a string in Python 3.1?

I have looked all around and only found solutions for python 2.6 and earlier, NOTHING on how to do this in python 3.X. (I only have access to Win7 box.) I HAVE to be able to do this in 3.1 and preferably without external libraries. Currently, I have httplib2 installed and access to command-prompt curl (that's how I'm getting the source ...

Google App Engine: Give arguments to a script from URL handler?

Here is a portion of my app.yaml file: handlers: - url: /remote_api script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py login: admin - url: /detail/(\d)+ script: Detail.py - url: /.* script: Index.py I want that capture group (the one signified by (\d)) to be available to the script Detail.py. How can I do this? Do...

Supporting PubSubHubbub with PyRSS2Gen?

I'm using PyRSS2Gen to generate a RSS feed and I'm trying to support PubSubHubbub, but I need to add link elements that break RSS. Here's what should work without requiring a rewrite as Atom: <atom:link rel="hub" href="http://example.hub.com" xmlns:atom="http://www.w3.org/2005/Atom"&gt; <atom:link rel="self" href="http://example.com" x...

datetime rendering in the admin forms

I have the following Model and ModelAdmin classes. However when I view the posts in the admin list page, the created fields are rendered as 2010-03-01 22:15:18.494594. I've tried setting the DATETIME_FORMAT variable in settings.py, but that didn't help. Any ideas how to control the formatting of datetime fields in the admin forms. PS...

In Python, what exactly does "import *" import?

Does it import __init__.py found in the containing folder? e.g., is it necessary to declare from project.model import __init__ or is from project.model import * sufficient? ...

Global function in __init__.py not accessible using Pylons + Python

I'm having trouble creating a global function accessible from within all classes. I receive an error from within user.py that says: NameError: global name 'connectCentral' is not defined Here is my current code. project/model/__ init __.py: """The application's model objects""" import sqlalchemy as sa from sqlalchemy im...