This may seem like the worlds simplest python question... But I'm going to give it a go of explaining it.
Basically I have to loop through pages of json results from a query.
the standard result is this
{'result': [{result 1}, {result 2}], 'next_page': '2'}
I need the loop to continue to loop, appending the list in the result key to...
I have a set of 52 or so latitude/longitude pairs. I simply need to find the shortest path through all of them; it doesn't matter where staring point or ending point is.
I've implemented Dijkstra's algorithm by hand multiple times before and don't really have the time to do it again. I've found a couple things that come close, but most...
I was trying to use http://www.jongsma.org/gc/scripts/ofx-ba.py to grab my bank account information from wachovia. Having no luck, I decided that I would just try to manually construct some request data using this example
So, I have this file that I want to use as the request data. Let's call it req.ofxsgml:
FXHEADER:100
DATA:OFXSGML
...
I'm interested how can be implemented recursive regexp matching in Python (I've not found any examples :( ). For example how would one write expression which matches "bracket balanced" string like "foo(bar(bar(foo)))(foo1)bar1"
...
We'd like to create a Django Intranet application for mass market. We only need to support Windows users, and it needs to be very easy for a Windows admin (or "technical user") to deploy (baring in mind that most Windows admins/users have little experience with Python, etc).
Is Django + py2exe the answer? Do we need something extra, or ...
Hello,
Using Python I need to transfer non utf-8 encoded data (specifically shift-jis) to a URL via the query string.
How should I transfer the data? Quote it? Encode in utf-8?
Thanks
...
I have a list of tuples I am trying to sort and could use some help.
The field I want to sort by in the tuples looks like "XXX_YYY". First, I want to group the XXX values in reverse order, and then, within those groups, I want to place the YYY values in normal sort order. (NOTE: I am just as happy, actually, sorting the second item ...
Dear all,
I am coding a python script that parses a text file. The format of this text file is such that each element in the file uses two lines and for convenience I would like to read both lines before parsing. Can this be done in python?
I would like to some something like:
f = open(filename, "r")
for line in f:
line1 = line
...
In my Django app, I have a mix of doctests (defined in models.py and views.py) and unit tests (defined in tests.py. I can invoke an individual unit test by doing:
manage.py test app.TestCase
However, this doesn't seem to work for the doctests. Is there some way to run a single doctest (defined in models.py or views.py)?
...
I'm trying to run a google search query from a python app. Is there any python interface out there? If there isn't does anyone know which Google API will enable me to do this. THanks
...
I've been wanting to write a python script that would run several instances of rsync in sequence for backing up data to a different computer.
At the moment I just have this text file with the commands I use and I've just been copy-pasting them into the terminal, and it seems kinda silly.
I want to be able to use python to do this for m...
This is a but of a part 2 in trying to convert an SVN repository to a Mercurial one
command is:
hg convert file://c:/svnrepository
but, the output I get is:
assuming destination svnrepository-hg
initializing destination svnrepository-hg repository
file://c:/svnrepository does not look like a CVS checkout
file://c:/svnrepository does...
I am using Django's unit testing apparatus (manage.py test), which is throwing an error and halting when the code generates a warning. This same code when tested with the standard Python unittest module, generates warnings but continues code execution through them.
A little research shows that Python can be set to raise warnings to exc...
I've seen in different code bases and just read on PyMOTW (see the first Note here).
The explanation says that a cycle will be created in case the traceback is assigned to a variable from sys.exc_info()[2], but why is that?
How big of a problem is this? Should I search for all uses of exc_info in my code base and make sure the traceback ...
I have a list:
l = [['en', 60, 'command'],['sq', 34, 'komand']]
I want to search for 'komand' or 'sq' and get l[1] returned.
Can I somehow define my own matching function for list searches?
...
I've run into a problem with mechanize following links. Here's a snippet of what I'm aiming to do:
for link in mech.links(url_regex='/test/'):
mech.follow_link(link)
// Do some processing on that link
mech.back()
According to mechanize examples, this should work just fine. However it doesn't. Despite calling .back(), the...
I'm interested in finding for a particular Numpy type (e.g. np.int64, np.uint32, np.float32, etc.) what the range of all possible valid values is (e.g. np.int32 can store numbers up to 2**31-1). Of course, I guess one can theoretically figure this out for each type, but is there a way to do this at run time to ensure more portable code?
...
I have two functions like the following:
def fitnesscompare(x, y):
if x.fitness>y.fitness:
return 1
elif x.fitness==y.fitness:
return 0
else: #x.fitness<y.fitness
return -1
that are used with 'sort' to sort on different attributes of class instances.
These are used from within other functions ...
I'm trying to generate random 64-bit integer values for integers and floats using Numpy, within the entire range of valid values for that type. To generate random 32-bit floats, I can use:
In [2]: np.random.uniform(low=np.finfo(np.float32).min,high=np.finfo(np.float32).max,size=10)
Out[2]:
array([ 1.47351436e+37, 9.93620693e+37, 2...
Hello,
I am after a Python module for Google App Engine that abstracts away limitations of the GQL.
Specifically I want to store big files (> 1MB) and retrieve all records for a model (> 1000). I have my own code that handles this at present but would prefer to build on existing work, if available.
Thanks
...