I need to write a query that returns all object less that or equal to a certain day of a certain month. The year is not important. It's easy enough to get an object by a particular day/month (assume now = datetime.datetime.now()):
posts = TodaysObject.objects.filter(publish_date__day=now.day, publish_date__month=now.month)
But I can't...
I wrote a small Python extension that bundles, compiles and statically links with a small C library with one optional .S (assembler) file. Distutils's Extension() doesn't recognize the .S by default. Is there a good way to compile that file, or should I just shell out to make? Right now I compile the C code only for a slightly slower lib...
Does python create a completely new string (copying the contents) when you do a substring operation like:
new_string = my_old_string[foo:bar]
Or does it use interning to point to the old data ?
As a clarification, I'm curious if the underlying character buffer is shared as it is in Java. I realize that strings are immutable and will ...
Hi,
I'm currently having trouble creating an image from a binary string of data in my Python program. I receive the binary data via a socket but when I try the methods I read about on here like this:
buff = StringIO.StringIO() #buffer where image is stored
#Then I concatenate data by doing a
buff.write(data) #the data from the socket...
If I create a recarray in this way:
In [29]: np.rec.fromrecords([(1,'hello'),(2,'world')],names=['a','b'])
The result looks fine:
Out[29]:
rec.array([(1, 'hello'), (2, 'world')],
dtype=[('a', '<i8'), ('b', '|S5')])
But if I want to specify the data types:
In [32]: np.rec.fromrecords([(1,'hello'),(2,'world')],dtype=[('a',np...
I am new to Django and I am trying to build a blog myself. I'm trying to create a feature I've seen implemented in Drupal using the nodequeue module.
What I want to do is to be able to create queues of objects, for example, queues of blog posts. Below, I describe how I imagine the queues to work:
the size of each queue should be user-...
Yesterday I asked ("A case of outwardly equal lists of sets behaving differently under Python 2.5 (I think …)") why list W constructed as follows:
r_dim_1_based = range( 1, dim + 1)
set_dim_1_based = set( r_dim_1_based)
def listW_fill_func( val):
if (val == 0):
return set_dim_1_based
else:
return set( [val])
W...
Is there some simple method that can check if an input object to some function adheres to a specific structure? For example, I want only a dictionary of string keys and values that are a list of integers.
One method would be to write a recursive function that you pass in the object and you iterate over it, checking at each level it is w...
I am looking for an example application written in Python and PyGTK.
There should be an editor out there somewhere that already does this.
Some app with a text editor row of buttons:
- Font
- Bold/italic/underline
- etc
I am hoping to avoid reinventing the wheel on this one!
thanks
...
I am working on a project in python using pygame and pyro. I can send data, functions, classes, and the like easily. However, I cannot send a surface across the wire without it dying on me in transit.
The server makes a surface in the def __init__ of the class being accessed across the wire:
self.screen = pygame.display.set_mode(SCREEN...
I try Netbeans 6.7 for python but don't have a good django template highlight and jquery code completion... i did find a project in google for django for netbeans but they don't explain how to do...
Also I try eclipse with pydev, but have some problems with code competion on my class...
I like to much Netbeans 6.7... I need more of jav...
Python loves raising exceptions, which is usually great. But I'm facing some strings I desperately want to convert to integers using C's atoi / atof semantics - e.g. atoi of "3 of 12", "3/12", "3 / 12", should all become 3; atof("3.14 seconds") should become 3.14; atoi(" -99 score") should become -99. Python of course has atoi and at...
Hello, I have a list of library filenames that I need to filter against regular expression and then extract version number from those that match. This is the obvious way to do that:
libs = ['libIce.so.33', 'libIce.so.3.3.1', 'libIce.so.32', 'libIce.so.3.2.0']
versions = []
regex = re.compile('libIce.so\.([0-9]+\.[0-9]+\.[0-9]+)')
for l ...
I am trying to configure the Python mini-framework CherryPy with FastCGI (actually fcgid) on Apache. I am on a shared host, so I don't have access to httpd.conf, just htaccess. I have followed these tutorials to no avail:
http://tools.cherrypy.org/wiki/FastCGIWSGI
http://tools.cherrypy.org/wiki/BluehostDeployment
I keep getting 500 e...
Consider these two classes:
class Test(int):
difference = property(lambda self: self.__sub__)
class Test2(int):
difference=lambda self: self.__sub__
Is there any difference between these two classes? New: If so, what is the purpose of using the property to store a lambda function that returns another function?
Update: Change...
I have a variable x in python. How can i find the string 'x' from the variable. Here is my attempt:
def var(v,c):
for key in c.keys():
if c[key] == v:
return key
def f():
x = '321'
print 'Local var %s = %s'%(var(x,locals()),x)
x = '123'
print 'Global var %s = %s'%(var(x,locals()),x)
f()
The results are:
Global va...
I'm using a crude IDE (Microchip MPLAB) with C30 toolchain on Windows XP.
The C compiler has a very noisy output that I'm unable to control, and it's very hard to spot actual warnings and errors in output window.
I want to write a python script that would receive arguments for compiler, call the compiler with same arguments, filter resu...
I've been trying to get MOD_WSGI working on Apache via XAMPP on my Mac OS X Snow Leopard all day today without any success. I've followed all the instructions, searched the internet for solutions, etc but no luck so far. Below are my exact steps and details. When I run localhost all I get is a white screen. When I remove "LoadModule wsgi...
Given an object, how do I tell if it's a class, and a subclass of a given class Foo?
e.g.
class Bar(Foo):
pass
isinstance(Bar(), Foo) # => True
issubclass(Bar, Foo) # <--- how do I do that?
...
Is there a full flegged python library for oauth? I haven't found any that handle reissuing of oauth tokens once they expire (Step 5 on the Yahoo OAuth flow).
So what is the most complete? I tried the one from oauth.net, and it doesn't handle oauth_session_handle which the oauth spec says is required if the endpoint returns it (like yah...