Hello, everyone
I cannot get a way to terminate a thread that is hung in a socket.recvfrom() call. For example, ctrl+c that should trigger KeyboardInterrupt exception can't be caught. Here is a script I've used for testing:
from socket import *
from threading import Thread
from sys import exit
class TestThread(Thread):
def __init_...
Hey Everybody,
i am working on a project, which i am developing with Python and PyQT4. I have stumbled upon a somewhat odd behaviour of the QFileDialog, that is not occuring when running the project within in my IDE (Eclipse).
The problem is that QFileDialog in ExistingFiles-mode does fail to return the list of selected files, when one...
Dear everyone,
I have successfully debugged my own memory leak problems. However, I have noticed some very strange occurence.
for fid, fv in freqDic.iteritems():
outf.write(fid+"\t") #ID
for i, term in enumerate(domain): #Vector
tfidf = self.tf(term, fv) * self.idf( term, docFreqDic)
...
I'm developing application for google app engine (python), witch needs not only to send emails, but also know which ones bounce back.
I created special account for my domain [email protected], added it as an app admin and sending messages from it.
The problem is (and it was described here http://code.google.com/p/googleappengine/issu...
For some code as follows,
opts, args = getopt.getopt(sys.argv[1:], "c:", ...
for o,v in opts:
...
elif o in ("-c", "--%s" % checkString):
kCheckOnly = True
clientTemp = v
If I don't give the parameter after the -c, I get the error messages as follows.
Traceback (most recent call last):
File...
Hi, I am wondering a good way to follow if i would like to redefine the members of a previous defined class in ipython.
say :
I have defined a class intro like below, and later i want to redefine part of the function definition _print_api. Any way to do that without retyping it .
class intro(object):
def _print_api(self,obj):
...
If I have two dictionaries I'd like to combine in Python, i.e.
a = {'1': 1, '2': 2}
b = {'3': 3, '4': 4}
If I run update on them it reorders the list:
a.update(b)
{'1': 1, '3': 3, '2': 2, '4': 4}
when what I really want is attach "b" to the end of "a":
{'1': 1, '2': 2, '3': 3, '4': 4}
Is there an easy way to attach "b" to the en...
I'm looking for a Python IDE that can help me easily locate and manage and use the libraries on my system (Ubuntu). Specifically Twisted.
Code completion is important including the symbols I import.
(I've so far had a look at PyDev as well as OpenKomodo, but while both offer code completion for default Python concepts, I wasn't able t...
I'm writing a scientific application in Python with a very processor-intensive loop at its core. I would like to optimise this as far as possible, at minimum inconvenience to end users, who will probably use it as an uncompiled collection of Python scripts, and will be using Windows, Mac, and (mainly Ubuntu) Linux.
It is currently writt...
I want to turn something like this
CS 240, CS 246, ECE 222, ... (more or less); Software Engineering students only
into
('CS 240', 'CS 246', 'ECE 222', 'ECE 220')
in Python, code that matches a single course looks like
>>> re.search('([A-Z]{2,5} \d{3})', 'SE 112').groups()
('SE 112',)
I prefer a regular expression only method be...
I've got a Codebase of around 5,3k LOC with around 30 different classe. The code is already very well formatted and I want to improve it further by prefixing methods that are only called in the module that were defined in with a "_", in order to indicate that. Yes it would have been a good idea to do that from the beginning on but now it...
I'm trying to learn python. I am using 3.1.2 and the o'reilly book is using 3.0.1
here is my code:
import urllib.request
price = (99.99)
while price > 4.74:
page = urllib.request.urlopen ("http://www.beans-r-us.biz/prices-loyalty.html")
text = page.read().decode("utf8")
where = text.find('>$')
start_of_price = where ...
I have a script that I want to exit early under some condition:
if not "id" in dir():
print "id not set, cannot continue"
# exit here!
# otherwise continue with the rest of the script...
print "alright..."
[ more code ]
I run this script using execfile("foo.py") from the Python interactive prompt and I would like the script ...
Is there a way to have any @property definitions passed through to a json serializer when serializing a Django model class?
example:
class FooBar(object.Model)
name = models.CharField(...)
@property
def foo(self):
return "My name is %s" %self.name
Want to serialize to:
[{
'name' : 'Test User',
'foo' : 'My name is Test User',...
Hi, I've got problems on getting django to work on apache 2.2 with mod_wsgi.
Django is installed and mod_wsgi too.
I can even see a 404 page when accessing the path and I can login to django admin.
But if I want to install the tagging module I get the following error:
Traceback (most recent call last):
File "setup.py", line 49, in <...
I would like to slice random letters from a string.
Given
s="howdy"
I would like to pick elements from 's' without replacement but keep the index number.
For example
>>> random.sample(s,len(s))
['w', 'h', 'o', 'd', 'y']
is close to what I want, but I would actually prefer something like
[('w',2), ('h',0), ('o',1), ('d',3), ('y',4...
I want to sort a list of strings based on the string length. I tried to use sort as follows, but it doesn't seem to give me correct result.
xs = ['dddd','a','bb','ccc']
print xs
xs.sort(lambda x,y: len(x) < len(y))
print xs
['dddd', 'a', 'bb', 'ccc']
['dddd', 'a', 'bb', 'ccc']
What might be wrong?
...
Hello, we are tasked with basically emulating a browser to fetch webpages, looking to automate tests on different web pages. This will be used for (ideally) console-ish applications that run in the background and generate reports.
We tried going with .NET and the WatiN library, but it was built on a Marshalled IE, and so it lacked many...
i need a simple implementation of ftp that i can setup quickly for some experiments.
is there an equivalent of python -m SimpleHTTPServer for ftp.
Google sarch didn't help.
i just need a simple implentation of ftp that is easy to setup. (so i don't have to go through the installation trouble for a lot of PC's).
...
Four consecutive bytes in a byte string together specify some value. However, only 7 bits in each byte are used; the most significant bit is always zero and therefore its ignored (that makes 28 bits altogether). So...
b"\x00\x00\x02\x01"
would be 000 0000 000 0000 000 0010 000 0001.
Or, for the sake of legibility, 10 000 0001. That's...