I'm writing a program that parses a 10 websites, locates data files, saves the files, and then parses them to make data that can be readily used in numpy. There are TONS of errors this file encounters through bad links, poorly formed xml, missing entries, and other things I've yet to categorize. I initially made this program to handle er...
I have a webapp, created using CakePhp. I need to interface with a Python script.
What is the best way to go about doing that?
(I could use pipe etc., but I want to check what the best practices are)
Thanks.
...
I've got a hundred 128 x 128 .pgm files with some shapes on them and I think their color scale is 255 (not sure on this one though, so it'd be nice if a solution could also take that in consideration) and I need to extract these colors to process the images. So what I'd like to end up with would be a 128 x 128 matrix with each element ha...
I use TextMate to debug python script, as I like the feature of using 'Command-R' for running python from TextMate, and I learned that emacs provide similar feature.
I need to know if the python is run from command line or from TextMate/emacs. How can I do that?
ADDED
I use TextMate for python coding/debugging, and it's pretty usefu...
Hi,
Does anyone know the java or groovy equivalent of a python for loop using izip?
python example:
for item_one, item_two in izip(list_one, list_two):
I'd like to do the same in java or groovy
Thanks
...
Hi,
there is more elegant (pythonic + effective) way to find word on given position?
FIRST_WORD = re.compile(r'^(\w+)', re.UNICODE)
LAST_WORD = re.compile(r'(\w+)$', re.UNICODE)
def _get_word(self, text, position):
"""
Get word on given position
"""
assert position >= 0
assert position < len(text)
# get secon...
I write a URL router in Python 3.1 and wonder whether it is more than a matter of taste to use one of the following variants:
Tuples as constructor params:
router = Router(
(r"/item/{id}", ItemResource()),
(r"/article/{title}", ArticleResource())
)
Method calls
router = Router()
router.connect(r"/item/{id}", ItemResource())...
I have a Python program which is going to take text files as input. However, some of these files may be gzip compressed. Is there a cross-platform, usable from Python way to determine if a file is gzip compressed or not? Is the following reliable or could an ordinary text file 'accidentally' look gzip-like enough for me to get false po...
I have to write a tool to get the encryption type out of a iwlist scan. I just can't seem to find whether or not there's a standard output. Googling it looks like people are posting slightly different formats, but I can't tell if they just copy/pasted wrong or what. Specifically, in Encryption key: On, is On/Off frist letter always capit...
Hello! Is it possible to set the position of an image using pygtk?
import pygtk
import gtk
class Example:
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.image = gtk.Image()
self.image.set_from_file("example.png")
# Position goes here (it should, shouldn't it?)
self.window.add(self.image)
self.image.show()
...
I'm trying to use Storm to create an ORM to an existing MySQL db. I'm trying to create a table Class for one of the tables but I'm getting this error:
storm.exceptions.ClassInfoError: <class 'statsstorm.Aggframe'> has no primary key information
This table has no primary key, or any combination of columns that produce a unique row. It...
I am trying to written this code which would just test whether a file exists and then reads it and prints.
I have written this code as a file named readFile.py and trying to run it through shell using execfile command. I have put many print stmts to check till where the control is going. The result shows me only first two print stmts and...
I've been writing python scripts that run locally. I would now like to offer a service online using one of these python scripts and through the webhosting I have I can run python in the cgi-bin.
The python script takes input from an html form filled in by the user, has the credentials and connects with a local database, calculates stuff...
I want to split my list into rows that have all the same number of columns, I'm looking for the best (most elegant/pythonic) way to achieve this:
>>> split.split_size([1,2,3], 5, 0)
[[1, 2, 3, 0, 0]]
>>> split.split_size([1,2,3,4,5], 5, 0)
[[1, 2, 3, 4, 5]]
>>> split.split_size([1,2,3,4,5,6], 5, 0)
[[1, 2, 3, 4, 5], [6, 0, 0, 0, 0]]
...
What are the top gotchas for someone moving from a static lang (java/c#) to dynamic language like python?
It seems cool how things can be done, but renaming a method, or adding/removing parameters seems so risky!
Is the only solution to write tests for each method?
...
My Django app stops working when deployed on Apache ( with mod_wsgi ).
It runs on a Windows server. The app calls on a windows executable called "rex" ( Alchemy Remote Executor ) which executes a command on another remote windows box.
process = subprocess.Popen( ['rex',ip,usr,pwd,command], stdout=subprocess.PIPE, universal_newlines=...
I have an command line interpreter (or "line-oriented command interpreter" in the python docs for the cmd module) for a program that I'd like to add command line utility interface to. For example, now a session looks like this: (% for shell prompt, :) is my custom prompt)
% tasks (invokes command line interpreter)
:) clockHours Teachin...
According to the documentation on ABCs, I should just have to add a next method to be able to subclass collections.Iterator. So, I'm using the following class:
class DummyClass(collections.Iterator):
def next(self):
return 1
However, I get an error when I try to instantiate it:
>>> x = DummyClass()
Traceback (most recent...
I have been trying to learn Python for a while now. By chance, I happened across chapter 6 of the official tutorial through a Google search link pointing
here.
When I learned, from that page, that functions were the heart of modules, and that modules could be called from the command line, I was all ears. Here's my first attempt at doing ...
I'm working on a Python application involving the use of a GTK table. The application requires that widgets of various sizes be added to a table dynamically. Because of this, I need to be able to ask the table what cells are in use (more accurately, NOT in use) so that I know where I can place a new widget without overlapping.
Based...