Someone from #python suggested that it's searching for module "herpaderp" and finding all the ones listed as its searching. If this is the case, why doesn't it list every module on my system before raising ImportError? Can someone shed some light on what's happening here?
import sys
class TempLoader(object):
def __init__(sel...
In Django there is a settings file that defines the middleware to be run on each request. This middleware setting is global. Is there a way to specify a set of middleware on a per-view basis? I want to have specific urls use a set of middleware different from the global set.
...
So, simply I want to be able to run a for across a list of URLs, if one fails then I want to continue on to try the next.
I've tried using the following but sadly it throws and exception if the first URL doesn't work.
servers = ('http://www.google.com', 'http://www.stackoverflow.com')
for server in servers:
try:
u = urllib2...
Python's sys module provides a function setrecursionlimit that lets you change Python's maximum recursion limit. The docs say:
The highest possible limit is platform-dependent.
My question is: What is the highest possible limits for various platforms, under CPython? I would like to know the values for Linux, Mac and Windows.
UPDAT...
cache.set(key, value, 9999999)
But this is not infinite time...
...
Hi,
I`m starting with PyQt4 and right now I have a problem with events.
I have one main class let say MainWindow. MainWindow has a list of buttons of type ButtonX (inherence form QPushButton). I would like to achieve one of 2 solutions (depends which is easier).
1) After click one of the button from the list I would like to run a one m...
I have a html form that posts to a python script test.py. If someone tries to access the script directly, it redirects them to the form.
I not using a web framework, just straight python cgi programming. My website is hosted on a shared hosting provider that allows me access to a .htaccess file.
I wanted to know if there was a way to h...
So I have a list of tuple like:
[(1,"juca"),(22,"james"),(53,"xuxa"),(44,"delicia")]
I want this list for a tuple whose number value is equal to something.
So that if I do search(53) it will return 2
Is is an easy way to do that?
...
cache.set(key, Biglist, 3600)
print cache.get(key)
When my "Biglist" is a huge list of lots of content, it doesn't seem to store.
But when I change it to small text like "abc", it stores.
What do I have to configure so that I can set my memcache to accept unlimited size of key/value?
...
How to call a method using getattr?
I want to create a metaclass, which can call non-existing methods of some other class that start with the word 'oposite_'. The method should have the same number of arguments, but to return the opposite result.
def oposite(func):
return lambda s, *args, **kw: not oposite(s, *args, **kw)
class ...
I'm needing to run Python scripts within a C-based app. I am able to import standard modules from the Python libraries i.e.:
PyRun_SimpleString("import sys")
But when I try to import a local module 'can'
PyRun_SimpleString("import can") returns the error msg:
Traceback (most recent call last):
File "", line 1, in...
We recently launched a new Django-powered website, and we are experiencing the oddest bug:
The site is running under Apache with mod_fastcgi. Everything works fine for a while, and then the URL tag and reverse() functionality stops working. Instead of returning the expected URL, they return "".
We haven't noticed anything in Apache's ...
Hi,
As a summer learning experiment, I'm thinking of coding up a web front end for a trading game i wrote in python, that generates share prices and random snippets of text.
I am sort of struggling with how this should work on the back-end though. I'd rather have my GWT client page interact with the python share price generator, than...
I know it is probably not necessary to paste the whole path, but just for the record I have done so below. Whenever I run a python command, it takes a long time to load this path I suppose. I have checked in .bash_profile and only have these two lines:
export PATH=/Users/username/bin:/opt/local/Library/Frameworks/Python.framework/Versio...
I'm no database expert -- I just know the basics, really. I've picked up SQLAlchemy for a small project, and I'm using the declarative base configuration rather than the "normal" way. This way seems a lot simpler.
However, while setting up my database schema, I realized I don't understand some database relationship concepts.
If I had a...
Hi, I'm trying to compute clusters on a set of points in Python, using GeoDjango.
The problem:
Given a set of points, output a set of clusters of those points.
(i'm fine specifying # of clusters/cluster size/distance in advance to simplify)
There are a few solutions on the web to do clustering, so it's a well known problem.
I thought ...
Hi, I'm writing a bare bones Python wsgi application and am getting stumped by module import errors. I have a .py file in the current directory which initially failed to import. By adding
sys.path.insert(0, '/Users/guhar/Sites/acom')
the import of the module worked. But I now try and import a module that I had installed via easy_instal...
My interests in programming lie mainly in algorithms, and lately I have seen many reputable researchers write a lot of their code in python. How easy and convenient is python for scientific computing? Does it have a library of algorithms that compares to matlab's? Is Python a scripting language or does it compile? Is it a great language ...
Is it possible to get the full path of the file on the user's computer being uploaded to my site?
Using os.path.abspath(fileitem.filename) simply gets me the address of where my script is executing from on my shared hosting server.
FYI: fileitem = form['file'] and form = cgi.FieldStorage()
...
Is there a way to stream audio and video over the internet using Python Web Programming and not Flash?
...