Suppose I have a function
def app2(environ, start_response)
If I know that a server implements WSGI, how can I tell the server to call app2 when it receives a HTTP request? app2 here is a function that takes a dictionary and returns a response (a WSGI application).
...
I'm working a small, personal Django project and I've added South (latest mercurial as of 10/9/10) to my project.
However, whenever I run "./manage.py syncdb" or "./manage.py migrate " I get about 13 pages (40 lines each) of output solely regarding 'initial_data' files not being found. I don't have any initial_data nor do I really want ...
I would like to improve the performance of a Python script and have been using cProfile to generate a performance report:
python -m cProfile -o chrX.prof ./bgchr.py ...args...
I opened this chrX.prof file with Python's pstats and printed out the statistics:
Python 2.7 (r27:82500, Oct 5 2010, 00:24:22)
[GCC 4.1.2 20080704 (Red Hat 4...
ciao!
I am using dns.resolver.
Is it possible to set the ip address of the server to use for the queries ?
Thanks, Massimo
...
The scenario is as follows: given a totally arbitrary starting date in UTC there is an event that repeats every 24 hours. I need to calculate, given the current local time, how much time is left before the next event.
Ideally an ideal function would do:
time_since_start = now - start_time
remaining_seconds = time_remaining(time_since_s...
Is 2.x still the norm or would you recommend just coding in v3 at this point?
...
I was writing debugging methods for my CherryPy application. The code in question was (very) basically equivalent to this:
import cherrypy
class Page:
def index(self):
try:
self.body += 'okay'
except AttributeError:
self.body = 'okay'
return self.body
index.exposed = True
cherryp...
I have seen a few different styles of writing docstrings in Python, is there an official or "agreed-upon" style?
...
Could anyone help me on how to write a python script that searches google and prints the links of top results.
...
Here LINK it is suggested that it is possible to "Figure out what the JavaScript is doing and emulate it in your Python code: " This is what I would like help doing ie my question. How do I emulate javascript:__doPostBack ?
Code from a website (full page source here LINK:
<a style="color: Black;" href="javascript:__doPostBack('ctl00$Co...
I have comtypes 0.6.2 installed on Python 2.6. If I try this:
import comtypes.gen
I get:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import comtypes.gen
ImportError: No module named gen
Other imports like import comtypes and import comtypes.client, however, work fine.
What am I doing wrong?
...
Hi,
I'm trying to figure out a way to transfer cookies from a Twill browser instance to a Zope browser instance. They both are built on Mechanize, so this should be possible.
I have tried:
zopeBrowser = zope.testbrowser.browser.Browser()
twillBrowser = twill.commands.get_browser()
twillBrowser.go("http://example.com/") # got some coo...
I am working on a text-based game in Python 3.1 that would use timing as it's major source of game play. In order to do this effectively (rather than check the time every mainloop, my current method, which can be inaccurate, and slow if multiple people are playing the game at once) I was thinking about using the Threading.Timer class. Is...
I am trying to install MySQLdb for Python 2.6 as per these instructions:
http://www.tutorialspoint.com/python/python_database_access.htm
When I get to this step: $ python setup.py build I get the error:
users-MacBook-Pro:MySQL-python-1.2.3 user$ sudo python setup.py build
sh: mysql_config: command not found
Traceback (most recent call...
I looked in my book and in the documentation, and did this:
a = "hello"
b = a.split(sep= ' ')
print(b)
I get an error saying split() takes no keyword arguments. What is wrong?
I want to have ['h','e','l','l','o']
I tried not passing sep and just a.split(' '), and got ['hello']
...
Hello. I'm writing a small app which has 2 separate frames.
The first frame is like a video player controller. It has Play/Stop/Pause buttons etc. It's named controller.py.
The second frame contains OpenGL rendering and many things inside it, but everything is wrapped inside a Frame() class as the above. It's named model.py.
I'm up to...
I want to use server.get_request() to receive requests, but I want it to timeout after 500 milliseconds. Is this correct? Doesn't seem to work... thanks.
class UDPServer(SocketServer.BaseRequestHandler):
timeout = .500
if __name__ == "__main__":
server = SocketServer.UDPServer(('localhost', '12345'), UDPServer)
server.get_r...
Hi Guys,
I love SO and have been using it for the last 2 years. I've never posted any questions on it (because I found most answers though SO's search).
I have high hopes for this question.
I have been a .NET developer for the last 7-8 years (ASP.NET, ASP.NET MVC etc) and now i want to learn something new, especially outside Wi...
I am new to python and i have a module that works fine with BeautifulSoup and parses the HTML file,
i want to use this module as a function on another file, but i copied almost the exact same code in the funcion but now i get this error: AttributeError: 'NoneType' object has no attribute 'findAll'
Here is the code of the module that wo...
Python's fcnt module provides a method called [flock][1] to proved file locking. It's description reads:
Perform the lock operation op on file
descriptor fd (file objects providing
a fileno() method are accepted as
well). See the Unix manual flock(2)
for details. (On some systems, this
function is emulated using fcntl().)fu...