I am creating a simple blog as part of a website and I am getting stuck on something that I am assuming is simple.
If I call any blog post, say by it's title, from a queryset, how can I get the entry before and after the post in it's published order.
I can iterate over the whole thing, get the position of the entry I have and use that ...
Hi All,
I have following:
temp = "aaaab123xyz@+"
lists = ["abc", "123.35", "xyz", "AND+"]
for list in lists
if re.match(list, temp, re.I):
print "The %s is within %s." % (list,temp)
The re.match is only match the beginning of the string, How to I match substring in between too.
...
i read the doc:
from google.appengine.api import mail
mail.send_mail(sender="[email protected]",
to="Albert Johnson <[email protected]>",
subject="Your account has been approved",
body="""
Dear Albert:
Your example.com account has been approved. You can now visit...
has a method in python likw setinterval function in javascript ?
thanks
...
I have a code snippet like this
class A(object):
class b:
def print_hello(self):
print "Hello world"
b = property(b)
And I want to override the inner class b (please dont worry about the lowercase name) behaviour. Say, I want to add a new method or I want to change an existing method, like:
class C(A):
...
I just came across Cython, while I was looking out for ways to optimize Python code. I read various posts on stackoverflow, the python wiki and read the article "General Rules for Optimization".
Cython is something which grasps my interest the most; instead of writing C-code for yourself, you can choose to have other datatypes in your p...
Hi there,
I'm serving a python script through WSGI. The script accesses a web resource through urllib, computes the resource and then returns a value.
Problem is that urllib doesn't seem to handle many concurrent requests to a precise URL.
As soon as the requests go up to 30 concurrent request, the requests slow to a crawl! :(
Help...
Having a class like this:
class Spam(object):
def __init__(self, name=''):
self.name = name
eggs = Spam('systempuntoout')
using dis, is it possible to see how an instance of a class and the respective hex Identity are created?
...
I have strange behavior of Sphinx searchd. I used it with Python standard client on ubuntu 9.10
For same query it's can give normal response or can give broken package like this:
failed to read searchd response (status=0,ver=1,len=278,read=72)
this problem appears with 50% probability.
I have test index with only 5 documents and defa...
Hi folks,
is it possible to perform urlopen requests from different IP addresses?
...
I installed Python Mock module using PIP.
When I try to import mock running under 'dev_appserver', GAE says that it can't find module 'mock'.
import mock works perfectly in Python interpreter.
I understand that dev_appserver behaves absolutely correctly because I can't install modules with PIP on GAE servers.
My question is how techn...
I have a string a and I would like to split it in half depending on its length, so I have
a-front = len(a) / 2 + len(a) % 2
this works fine in the interpreter but when i run the module from the command line python gives me a SyntaxError: can't assign to operator. What could be the issue here.
...
I was working the following example from Doug Hellmann tutorial on multiprocessing:
import multiprocessing
def worker():
"""worker function"""
print 'Worker'
return
if __name__ == '__main__':
jobs = []
for i in range(5):
p = multiprocessing.Process(target=worker)
jobs.append(p)
p.start()
W...
I am using python in Linux to automate an excel. I have finished writing data into excel by using pyexcelerator package.
Now comes the real challenge. I have to add another tab to the existing sheet and that tab should contain the macro run in the first tab. All these things should be automated. I Googled a lot and found win32come to d...
Hello.
I have text file with several thousands lines. I want to parse this file into database and decided to write a regexp. Here's part of file:
blablabla checked=12 unchecked=1
blablabla unchecked=13
blablabla checked=14
As a result, I would like to get something like
(12,1)
(0,13)
(14,0)
Is it possible?
...
I am trying to install dateutils on OS X 10.6. When I run python setup.py install it installs fine but to the Python 2.6 directory. I need to use Python 2.5 which is the "default" python version. By this I mean that when I run python from the command line it loads Python 2.5.4.
Is there a way to install modules to specific versions of ...
I know Twisted can do this well but what about just plain socket?
How'd you tell if you randomly lost your connection in socket? Like, If my internet was to go out of a second and come back on.
...
I'm trying to do this again an Oracle 10 database:
cursor = connection.cursor()
lOutput = cursor.var(cx_Oracle.STRING)
cursor.execute("""
BEGIN
%(out)s := 'N';
END;""",
{'out' : lOutput})
print lOutput.value
but I'm getting
DatabaseError: ORA-01036: illegal variable name/number
Is...
How to start a programm with Python?
I thougt this would be very easy like:
open(r"C:\Program Files\Mozilla Firefox\Firefox.exe")
But nothing happen.
How to do this?
Thanks in advance.
...
I'm trying to make a very large file editor (where the editor only stores a part of the buffer in memory at a time), but I'm stuck while building my textview object. Basically- I know that I have to be able to update the text view buffer dynamically, and I don't know hot to get the scrollbars to relate to the full file while the textvie...