Out of the various ways to import code, are there some ways that are preferable to use, compared to others? This link http://effbot.org/zone/import-confusion.htm in short
states that
from foo.bar import MyClass
is not the preferred way to import MyClass under normal circumstances or unless you know what you are doing. (Rather, a bette...
EDIT
I solved the issue by forking the process instead of using threads. From the comments and links in the comments, I don't think threading is the right move here.
Thanks everyone for your assistance.
FINISHED EDIT
I haven't done much with threading before. I've created a few simple example "Hello World" scripts but nothing that ac...
A little background:
I want to use Django Search with Lucene
I have Django 1.1 w/ Python 2.5 installed
MySQL 5.1 is being used
My local machine is running Windows Vista x64, but we will deploy to Red Hat Linux
Yes, I wish that right about now I was running Linux.
...
I'm looking for a simple process-based parallel map for python, that is, a function
parmap(function,[data])
that would run function on each element of [data] on a different process (well, on a different core, but AFAIK, the only way to run stuff on different cores in python is to start multiple interpreters), and return a list of resu...
Using gzip, tell() returns the offset in the uncompressed file.
In order to show a progress bar, I want to know the original (uncompressed) size of the file.
Is there an easy way to find out?
...
Zope Interfaces are a great way to get some Java-style "design by contract" into a python program. It provides some great features such as implement-able interfaces and a really neat pattern for writing adaptors for objects.
Unfortunately, since it's part of a very mature platform which runs just fine on Python 2.x the developers of Zo...
What is the difference between yield keyword in Python and yield keyword in C#?
...
Which Distributed Hash Table (DHT) is easiest to implement in Python? Any good example that is not bloated?
I not am looking for a definition of DHT because I am more oriented and focused on design and implementation of such.
...
So lets say there's a server process that takes way too long. The client complains that it "times out."
Correct me if I'm wrong, but this particular timeout could have to do with apache's timeout setting, but not necessarily. I believe this to be the case because when testing the page in question we couldn't get it to time out reliably ...
I currently use mechanize to read gzipped web page as below:
br = mechanize.Browser()
br.set_handle_gzip(True)
response = br.open(url)
data = response.read()
I wonder how to decompress gzipped data fetched by urllib2 to HTML text?
req = urllib2.Request(url)
opener = urllib2.build_opener()
response = opener.open(req)
data = response.r...
Suppose there are 10,000 JPEG, PNG images in a gallery, how to find all images with similar color palettes to a selected image sorted by descending similarity?
...
I have the following code:
r = numpy.zeros(shape = (width, height, 9))
It creates a width x height x 9 matrix filled with zeros. Instead, I'd like to know if there's a function or way to initialize them instead to NaN.
Is there any? Without having to resort to manually doing loops and such?
Thanks
...
Hello,
Through my web interface I would like to start/stop certain processes and determine whether a started process is still running.
My existing website is Python based and running on a Linux server, so do you know of a suitable library that supports this functionality?
Thanks
...
django.forms is very nice, and does almost exactly what I want to do on my current project, but unfortunately, Google App Engine makes most of the rest of Django unusable, and so packing it along with the app seems kind of silly.
I've also discovered FormAlchemy, which is an SQLAlchemy analog to Django forms, and I intend to explore t...
Hi all,
Our projects at work include synchronous applications (short lived) and asynchronous Twisted applications (long lived). We're re-factoring our database and are going to build an API module to decouple all of the SQL in that module. I'd like to create that API so both synchronous and asynchronous applications can use it. For the ...
I would like to create a library, say foolib, but to keep different subpackages separated, so to have barmodule, bazmodule, all under the same foolib main package. In other words, I want the client code to be able to do
import foolib.barmodule
import foolib.bazmodule
but to distribute barmodule and bazmodule as two independent entitie...
hi all,
i am working with complex networks. I want to find group of nodes which forms cycle of 3 nodes ( or triangles) in a given graph. As my graph contains about million edges, so the use simple iterative (multiple "for" loop) is not very efficient.
If someone knows any algorithm which can be used for finding triangles in graphs, kind...
I'm trying to teach myself python using Google's AppEngine, and I can't get the dev server running. I get this error:
Traceback (most recent call last):
File "/opt/google_appengine/google_appengine_1.2.7/dev_appserver.py",
line 60, in
run_file(file, globals()) File
"/opt/google_appengine/google_appengine_1.2.7/dev_apps...
Is there an extra for Python Markdown that supports Markdown inside HTML block elements, e.g. div, p
i.e. is there a way to convert this:
<div id="content">
[Google](http://www.google.com)
</div>
to
<div id="content">
<a href="http://www.google.com>Google</a>
</div>
using Python Markdown or a Python Markdown exten...
I wrote code like this
>>> class a(object):
def __init__(self):
self.__call__ = lambda x:x
>>> b = a()
I expected that object of class a should be callable object but eventually it is not.
>>> b()
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
b()
TypeError: 'a' object is not callable
>>> ...