I am working with a 2D Numpy masked_array in Python.
I need to change the data values in the masked area such that they equal the nearest unmasked value.
NB. If there are more than one nearest unmasked values then it can take any of those nearest values (which ever one turns out to be easiest to code…)
e.g.
import numpy
import numpy.m...
Is there a way in Python to initialize a multi-dimensional array / list without using a loop?
...
I've got a PyQt app which I'm developing in Mac OS X, and whenever I try launching the app, it always is the very bottom application on the stack. So after launching, I always need to command+tab all the way to the end of the application list to switch focus to it.
I read that this behavior can be fixed by launching the app with the "p...
I'm trying to use fabric to deploy a Django project and I get this error when I run hg pull:
[myusername.webfactional.com] run: hg pull
[myusername.webfactional.com] out: remote: Warning: Permanently added the RSA host key for IP address '207.223.240.181' to the list of known hosts.
[myusername.webfactional.com] out: remote: Permission ...
I like the comment box at the top with the posts going in reverse order. Comment rating, highest rated comments, all great features, remaining character count, spam flag.
My question is, is there a open commenting system available for Django that already has these features?
...
Hi,
I'm very new to Python, sort of following Dive into Python 2 and wanted to dabble with some Tkinter programming. I've tried to make a little program that takes 3 sets of words and makes combinations of each word in the 3 sets to make keywords for websites. When I run the script, the GUI appears as expected, but I get the following e...
I am trying to use the |date filter and running into some problems. Here is the code that outputs an unformatted way:
{% for the_date in event.date_set.all %}
<p>{{ the_date }}</p>
{% endfor %}
this outputs
<p>2010-10-31</p>
<p>2010-12-01</p>
...etc
When I change the code to
{% for the_date in event.date_set.all %}
<p>{{ the_...
i have a bunch of strings
some of them have ' rec'
i want to remove that only if those are the last 4 characters
so another words
somestring='this is some string rec'
i want it to be:
somestring='this is some string'
what is the python way to approach this?
...
What is the most efficient way one would go about retrieving the U.S. Postal zip code for a street address using Python? Is this something that is even possible?
Preferably, something that includes a local database as oppose to a remote API call of some sort.
Thanks in advance for any help one may be able to offer.
...
Is it possible to have a RTSP media server send to different IP's and/or MAC's with one client in python?
I am trying to stress test a server by having it send to multiple IP's while still seeing if there have been any dropped packets on any of the streams. I haven't been able to figure out a way to tell the server to send to more than ...
I have multiple forms in a Django project. I was trying to use the Django provided as_p for form displaying due to its simplicity but client wants the error list below the field. Django's as_p prints it above the field label. I rather not add a field printing loop in every template just for this small change. It seems like the least effi...
Hi Everyone,
Simple question, I've scaled down a problem I'm having where a list which I've retrieve from an object is changing when I append more data to the object. Not to the list.
Can anyone help my understand the behavior of python?
class a():
def __init__(self):
self.log = []
def clearLog(self):
del self...
I've been searching for an elegant way to represent a multi-select weekday field (Mon, Tues, Wed...) in a Django model. I was initially thinking of going integer field using bitwise math but I am not sure if this would be the way to go.
This would be a mostly-read field. I would want the Queryset method to be something like Entry.object...
I have substantial PHP experience, although I realize that PHP probably isn't the best language for a large-scale web crawler because a process can't run indefinitely. What languages do people suggest?
...
So I'm working with a block of code which communicates with the Flickr API.
I'm getting a 'syntax error' in xml.parsers.expat.ExpatError (below). Now I can't figure out how it'd be a syntax error in a Python module.
I saw another similar question on SO regarding the Wikipedia API which seemed to return HTML intead of XML. Flickr API r...
I have a text file with html:
Blah, blah, blah
some text is here.
<div> something here
something else </body></html>
so far, if the tags are on one line this works:
textfile = open("htmlfile.txt", "r+")
text = textfile.read()
a = re.search('<div.+?<\/html>', text)
repstr = c.group(0)
text = text.replace(repstr, '', 1)
works ...
I'm not sure why this application is not displaying anything. I'll reproduce in a few lines to provide the gist of the issue. Using PyQt4
class SomeScene(QtGui.QGraphicsScene):
def __init__(self, parent = None):
QtGui.QGraphicsScene.__init__(self, parent)
pixmap = QtGui.QPixmap('someImage') # path is DEFINITELY vali...
I want to publish to the wall of a Facebook Fan Page, from a python/django web application.
The new Graph API looks nice and simple, so I'd like to use that. Unless there is a much easier way :-) I'm guessing the pyFacebook package would do want I want, but it appears to use the old rest interface. pyFacebook is probably a complete o...
I am trying to dynamically create module level functions from the methods in a class. So for every method in a class, I want to create a function with the same name which creates an instance of the class and then calls the method.
The reason I want to do this is so I can take an object-oriented approach to creating Fabric files. Since F...
I was hoping that putting 'sys.exit(1)' and catching it later like this will work.
xml_open()
try:
run(reloader=True, host='localhost', port=8080)
except SystemExit:
xml_save()
print "Exited ..."
Is there any other solution to exit these python micro-frameworks to exit from inside
the handlers ?
...