I have a Django model Reminder related to Event model.
class Reminder(models.Model):
email = models.EmailField("e-mail")
event = models.ForeignKey(Event, unique=True, related_name='event',)
date = models.DateTimeField(_(u"Remind date"), auto_now_add=False,)
class Event(models.Model):
date = models.DateTimeField(_(u"Even...
Forms have Fields. Fields have a Widget. If a Field name is omitted, it takes the variable name specified in the form. For example,
MyForm(Form):
username = Field(name=None, widget=MyWidget(args))
The field name would become "username". However, this can't be established until the form is constructed. Would it be so awful to set t...
I want to send emails from my app engine application using one of my Google Apps accounts. According to the GAE python docs:
The From: address can be the email address of a registered administrator (developer) of the application, the current user if signed in with Google Accounts, or any valid email receiving address for the app (that ...
This following is a straightforward IPv4 UDP broadcast, followed by listening on all interfaces.
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, True)
sock.bind(("", 1337))
sock.sendto("hello world", ("255.255.255.255", 1337))
while True:
data, addr = sock.recvfrom(0x10...
Forms have Fields, Fields have a value. However, they only get a value after the form has been submitted.
How should I store this value? Should I give every field a value attribute, field.value,
leave it as None prior to posting, and fill it in afterwords?
Omit it completely, and dynamically add it?
Store it on the form instead, li...
I want my Python script to access a URL through an IP specified in the script instead of through the default DNS for the domain. Basically I want the equivalent of adding an entry to my /etc/hosts file, but I want the change to apply only to my script instead of globally on the whole server. Any ideas?
...
Hello. Consider this code:
>>> LISTL = []
>>> VAR1 = 0
>>> def foo():
... VAR1 += 1
... return VAR1
...
On calling foo(), I get this error:
UnboundLocalError: local variable 'VAR1' referenced before assignment
However, consider the list LISTL
>>> def foo(x):
... LISTL.append(x)
... return LISTL
...
>>> foo(5)
[5]...
now() gives me
datetime.datetime(2010, 7, 6, 5, 27, 23, 662390)
How do I get just datetime.datetime(2010, 7, 6, 5, 27, 0, 0) (the datetime object) where everything after minutes is zero?
...
Hi,
I tried loading C shared library .so in Python using ctypes.CDLL class (Linux). Here is the link to which tells what I did. As I see the documentation it says CDLL class assumes that function returns int types. I've a doubt here what if I need to return variable of type other than the int type from a function in C?.
And to what exte...
I'm using django's built-in contrib.auth module and have setup a foreign key relationship to a User for when a 'post' is added:
class Post(models.Model):
owner = models.ForeignKey('User')
# ... etc.
Now when it comes to actually adding the Post, I'm not sure what to supply in the owner field before calling save(). I expected ...
Possible Duplicate:
How do you split a list into evenly sized chunks in Python?
Hello,
I'm trying to find a simpler way to do the following:
def list_split(list, size):
result = [[]]
while len(list) > 0:
if len(result[-1]) >= size: result.append([])
result[-1].append(list.pop(0))
return result
Example usage:
...
Possible Duplicate:
Getting CPU temperature using Python?
What is the simplest method of going about this? Also preferably in Celsius.
...
I have a small Python program consisting of very few modules (about 4 or so). The main module creates a list of tuples, thereby representing a number of records. These tuples are available to the other modules through a simple function that returns them (say, get_records()).
I am not sure if this is good design however. The problem be...
I installed opencv in my mac using mac ports by the following command
sudo port install opencv
It took around 2 hours and it installed properly. But the problem is that the python bindings are not enabled.
So please let me know how to install opencv in mac using ports and also enable the python bindings. Thanks
PS: I tried to manuall...
Hi,
Please help me, I am getting MemoryError when trying to fetch a specific email. This is the error message:
python(23838,0x1888c00) malloc: *** vm_allocate(size=3309568) failed (error code=3)
python(23838,0x1888c00) malloc: *** error: can't allocate region
python(23838,0x1888c00) malloc: *** set a breakpoint in szone_error to debug
...
Ive been looking at the principles of fan out of messages as described in the google IO "building scalable complex apps"
In it it suggests that using a list property for say a list of receivers is a scalable solution.
In this scenario how does one update the list property so that contention issues don't step in, If the app is handling ...
Hello,
What would be the best python based library for generating 8-bit palette from the given .png file.
As in photoshop generating under .pal format.
PS: Input PNG is already in 8 bit format. (paletted)
Regards
...
Howdy,
I've written a python script which does some curses and pysqlite stuff, but I've noticed that in occasions where I've been running this script over ssh when that ssh session is killed for whatever reason the python script doesn't actually exit, instead it ends up as being a child of init and just stays there forever. I can't kill...
Hi All,
I would like to use thread to process a streaming input.
How can make the below code for an infinite input generate for example by using itertools.count
The code below will work if:
'for i in itertools.count():' is replaced by 'for i in xrange(5):'
from threading import Thread
from Queue import Queue, Empty
import itertools...
This may or may not being a coding issue. It may also be an xinetd deamon issue, i do not know.
I have a python script which is triggered from a linux server running xinetd. Xinetd has been setup to only allow one instance as I only want one machine to be able to connect to the service, which is therefore also limited by IP.
Currently...