I can't use wx.ProgressDialog because I need to add extra contents to the dialog box (a pause button and information about what is currently being processed). Is there a control for just the progress bar that I can use in my own dialog box?
I could of course draw something simple myself, but since the program needs to run on Mac OS X, ...
Hi,
I am trying to read a gunzipped file (.gz) in python and am having some trouble.
I used the gzip module to read it but the file is encoded as a utf-8 text file so eventually it reads an invalid character and crashes.
Does anyone know how to read gzip files encoded as utf-8 files? I know that there's a codecs module that can help ...
Ok, a great example of what I am trying to achieve is at Google Translate. The URL: http://translate.google.com/#en|es|this is what I am trying to do makes a GET request using this URL: http://translate.google.com/translate_a/t?client=t&text=this%20is%20what%20I%20am%20trying%20to%20do&sl=en&tl=es&otf=1&pc=0
I'm not ...
Are there any good modules that you can run against your code to catch coding errors? I expected pylint to catch mistakes in the use of default arguments to functions like this:
>>> def spam(eggs=[]):
... eggs.append("spam")
... return eggs
but was disappointed to find them unreported. I am looking for something beyond PEP8 fo...
This seems like it should be pretty trivial, but I am new at Python and want to do it the most Pythonic way.
I want to find the n'th occurrence of a substring in a string.
There's got to be something equivalent to what I WANT to do which is
mystring.find("substring", 2nd)
How can you achieve this in Python?
...
I have a list of lists (generated with a simple list comprehension):
>>> base_lists = [[a, b] for a in range(1, 3) for b in range(1, 6)]
>>> base_lists
[[1,1],[1,2],[1,3],[1,4],[1,5],[2,1],[2,2],[2,3],[2,4],[2,5]]
I want to turn this entire list into a tuple containing all of the values in the lists, i.e.:
resulting_tuple = (1,1,1,2...
How can I simulate the following Python function using the Python C API?
def foo(bar, baz="something or other"):
print bar, baz
(i.e., so that it is possible to call it via:
>>> foo("hello")
hello something or other
>>> foo("hello", baz="world!")
hello world!
>>> foo("hello", "world!")
hello, world!
)
...
I took this script from here:
import csv
from itertools import izip
f = open( '/django/sw2/wkw2/csvtest1.csv', 'r' )
reader = csv.reader( f )
keys = ( "firm_url", "firm_name", "first", "last", "school", "year_graduated" )
out = []
for property in reader:
property = iter( property )
data = {}
for key in keys:
data[ key ...
In my Django webapp, in one location users can upload a text file where each line contains a string which will be operated on - the file isn't being stored on the server or anything like that.
My code looks like this:
roFile = request.FILES['uploadFileName']
ros = roFile.read().strip()
ros = ros.split('\n')
ros = [t.strip() for t in ro...
So I was reading the following documentation on defining your own property types in GAE. I noticed that I could also include a .validate() method when extending a new Property. This validate method will be called "when an assignment is made to a property to make sure that it is compatible with your assigned attributes". Fair enough, but ...
When I started writing this question, I didn't think of the easy solution with nested lists, but now anyway want to find one.
Here's an ugly code:
fun0(
fun1(fun2(fun3(arg1))),
fun1(fun2(fun3(arg4))),
fun1(fun2(fun3(arg4))),
fun1(fun2(fun3(arg4))))
Ouch! Names are given for examples. In the real application, their nam...
It seems that everytime I call a function that returns a PyObject*, I have to add four lines of error checking. Example:
py_fullname = PyObject_CallMethod(os, "path.join", "ss", folder, filename);
if (!py_fullname) {
Py_DECREF(pygame);
Py_DECREF(os);
return NULL;
}
image = PyObject_CallMethodObjArgs(pygame, "image.load", py_...
My plan is to collect data from websites in batches (lawyer bios from each firm's website; since they are all different, I will use a modified spider for each site) and convert each batch into a csv file; then to json; and then load it to database. So I will need to append each new file to the existing database. Please let me know how to...
Increasingly I found myself using tools based upon python, particularly that use installation processes involving easy_install. The trouble for me is that I am
On an intranet with no internet access
On windows (which always complicates things a little!)
Any advice on how to setup easy_install on my intranet to make using python bas...
I'm using django-notification to allow my users to opt out of certain alerts I generate in my web-application.
By default when I create a new notice type it is enabled rather than disabled In the users notification interface (checked)
I'd like to make some alerts opt-in rather than the default of opt out. I've looked through the docs ...
I created a "fixtures" folder in the app directory and put data1.json in there.
This is what is in the file:
[{"firm_url": "http://www.graychase.com/kadam", "firm_name": "Gray & Chase", "first": " Karin ", "last": "Adam", "school": "Ernst Moritz Arndt University Greifswald", "year_graduated": " 2004"} ]
In the command line I cd to t...
I have a huge table and I need to process all rows in it. I'm always getting this Lost connection message and I'm not able to reconnect and restore the cursor to the last position it was. This is basically the code I have here:
#
import MySQLdb
class DB:
conn = None
def connect(self):
self.conn = MySQLdb.connect('hostname', 'u...
I have a program spawning and communicating with cpu heavy, unstable processes, not created by me. If my app crashes or is killed by sigkill, I want the subprocesses to get killed as well, so the user don´t have to track them down and kill them manually.
I know this topic has been covered before, but I have tried all methods described, ...
Greetings,
I want to write a script that handles simple http requests from Google Earth and sends back KML to display map tiles that are stored locally. I would LIKE to use Python but any language is fine. I have not ever done anything with CGI, but I think this is the simplest way to accomplish my task. This is what the Google KML d...
In python's OptionParser, how can I instruct it to ignore undefined flag arguments supplied to method parse_args?
e.g.
I've only defined option --foo for my OptionParser instance, but I call parse_args with list [ '--foo', '--bar' ]
EDIT:
I don't care if it filters them out of the original list. I just want undefined options ignored...