Hello. Is it any easy way to use cherrypy as an web server that will display .html files in some folder? All cherrypy introductory documentation states that content is dynamically generated:
import cherrypy
class HelloWorld(object):
def index(self):
return "Hello World!"
index.exposed = True
cherrypy.quickstart(HelloWorl...
Are there any performance considerations for using a lot of generators chained together, as opposed to just a single generator.
For example:
def A(self, items):
for item in self.AB(items):
if object.A():
yield item
def AB(self, items):
for object in self.ABC(objects):
if object.A() or object.B():
...
When I typed:
>>> astrd = 123
>>> import sys
>>> sys.getrefcount(astrd)
3
>>>
I am not getting where is astrd used 3 times ?
...
Is it possible to retrieve an entity from google appengine using their numerical IDs and if so how?
I tried using:
key = Key.from_path("ModelName", numericalId)
m = ModelName.get(key)
but the key generated wasnt correct.
...
Due to performance reasons I can't use the ORM query methods of Django and I have to use raw SQL for some complex questions. I want to find a way to map the results of a SQL query to several models.
I know I can use the following statement to map the query results to one model, but I can't figure how to use it to be able to map to relat...
I'm keeping track of a user status on a model. For the model 'Lesson' I have the status 'Finished', 'Learning', 'Viewed'. In a view for a list of models I want to add the user status. What is the best way to do this?
One idea: Adding the request to a models method would do the trick. Is that possible?
Edit: I meant in templatecode: {{ ...
I have following code
import sys
from ctypes import *
from ctypes.util import find_library
libc = cdll.LoadLibrary(find_library("c"))
CTL_KERN = 1
KERN_SHMMAX = 34
sysctl_names = {
'memory_shared_buffers' : (CTL_KERN, KERN_SHMMAX),
}
def posix_sysctl_long(name):
_mem = c_uint64(0)
_arr = c_int * 2
_name = _arr()
...
link text
I got the concept of reference count
So when i do a "del astrd" ,reference count drops to zero and astrd gets collected by gc ?
This is the sample codes.These codes I developed after my yesterday's question:link text
one.py:
def abc():
print "Hello"
print "123"
print '345'
two.py:
import one
#reload(one)
#def defg():
...
I have a python process (Pylons webapp) that is constantly using 10-30% of CPU. I'll improve/tune logging to get some insight of what's going on, but until then, are there any tools/techniques that allow to see what python process is doing, how many and how busy threads it has etc?
Update:
configured access log which shows that there ...
I am taking a session on web application development using django at a local Open Source Community.
The audience has earlier programming experience in Java or C; Some people with php and .net.
What all should I talk about. Hardly anybody would be familiar with dynamic languages. How to cover essential topics of Python?
Are there any ...
I'm trying to find a way to mark a USB flash device in a way that I can programmaticly test for without mounting it or changing the label.
Are there any properties I can modify about a device that will not cause it to behave/look differently to the user?
Running Ubuntu Jaunty.
...
I maintain a cross platform application, based on PyQt that runs on linux mac and windows.
The windows and mac versions are distributed using py2exe and py2app, which produces quite large bundles (~40 MB).
I would like to add an "auto update" functionality, based on patches to limit downloads size:
check for new versions on an http s...
Hello people,
I'm using a python generator function to provide me with a list of images in the current directory. However I see the function is giving out the entire list twice instead of one time and I have no idea why. I'm using the Python PIL library to create batch thumbnails.
Can anyone point me in the right direction?
Thanks in ...
a = [] a.append(lambda x:x**0)
a.append(lambda x:x**1)
a[0](2), a[1](2), a[2](2)... spits out 1, 2, 4, ...
b=[]
for i in range(4)
b.append(lambda x:x**i)
b[0](2), b[1](2), b[2](2)... spits out 8, 8, 8, ...
In the for loop, the i is being passed to lambda as a variable, so when I call it, the last value of i is used instead of t...
How do I process the elements of a sequence in batches, idiomatically?
For example, with the sequence "abcdef" and a batch size of 2, I would like to do something like the following:
for x, y in "abcdef":
print "%s%s\n" % (x, y)
ab
cd
ef
Of course, this doesn't work because it is expecting a single element from the list which its...
I have a python module written in C, and I would like to add a function that is called when the module is unloaded. I obviously have an initfoo function to initialize the module -- is there a way to tell python to call a finifoo function when it's uninitializing the module?
Is atexit my only option?
...
I want to run a tail -f logfile command on a remote machine using python's paramiko module. I've been attempting it so far in the following fashion:
interface = paramiko.SSHClient()
#snip the connection setup portion
stdin, stdout, stderr = interface.exec_command("tail -f logfile")
#snip into threaded loop
print stdout.readline()
I'd...
Hello, I'm trying to code something that downloads a file from a webserver and saves it, showing the download progress in a QProgressBar.
Now, there are ways to do this in regular Python and it's easy. Problem is that it locks the refresh of the progressBar. Solution is to use PyQT's QNetworkManager class. I can download stuff just fine...
Is there a way to globally suppress the unicode string indicator in python? I'm working exclusively with unicode in an application, and do a lot of interactive stuff. Having the u'prefix' show up in all of my debug output is unnecessary and obnoxious. Can it be turned off?
...
I started to use the csv.reader in Python 2.6 but you can't use len on it, or slice it, etc. What's the reason behind this? It certainly feels very limiting.
Or is this just an abandoned module in later versions?
...