I'm having a bad time with date parsing and formatting today.
Points for somebody who can parse this date format into a datetime.date or datetime.datetime (I'm not too fussy but I'd prefer .date):
5th November 2010
...
Assuming a team of developers are equally comfortable with writing Javascript on the server side as they are with Python & Twisted, when is Node.js going to be more appropriate than Twisted (and vice versa)?
...
Is there any examples or for that matter bindings for python in order to use A2DP in python for ubuntu 10.04?
...
I have a Django application being served of (say) example.com. It contains a number of sub-applications (say) strength, speed and skill. The URL scheme is something like http://example.com/strength, http://example.com/speed and http://example.com/skill. This is how I run my dev server (using runserver) and there are no problems whatsoeve...
I am using BeautifulSoup in Python and am having trouble replacing some tags. I am finding <div> tags and checking for children. If those children do not have children (are a text node of NODE_TYPE = 3), I am copying them to be a <p>.
from BeautifulSoup import Tag, BeautifulSoup
class bar:
self.soup = BeautifulSoup(self.input)
foo()...
Disclaimer: I'm pretty terrible with multithreading, so it's entirely possible I'm doing something wrong.
I've written a very basic raytracer in Python, and I was looking for ways to possibly speed it up. Multithreading seemed like an option, so I decided to try it out. However, while the original script took ~85 seconds to process...
With Python2.6, the Evt module (from Carbon import Evt) does not have seem to respond to TickCount() on OSX. But Python2.5 is fine:
from Carbon import Evt
s = Evt.TickCount()
On Python2.5 I get a returned integer. On Python2.6 I get:
AttributeError: 'module' object has no attribute 'TickCount'
This is on Snow Leopard. Is there some...
I have two lists in Python, like these:
temp1 = ['One', 'Two', 'Three', 'Four']
temp2 = ['One', 'Two']
I need to create a third list with items from the first list which aren't present in the second one. From the example I have to get:
temp3 = ['Three', 'Four']
Are there any fast ways without cycles and checking?
...
Is there way to make custom signal when ManyToMany relations created?
...
I have code that looks like something like this:
def startSearching(self):
self.searchingLock.acquire()
searching = self.searching
if self.searching:
self.searchingLock.release()
self.logger.error("Already searching!")
return False
self.searching = True
self.searchingLock.release()
#some...
Ok I have some code that boils down to a pattern like this
class Foo(object):
def get_something1(self):
# in the actual code it asks a web server but here I replaced that with "foo_something1" instead of the code from a web server
self.something1 = "foo_something1"
def get_something2(self):
# needs the result of get_someth...
I have a client connected to a server using twisted. The client has a thread which might potentially be doing things in the background. When the reactor is shutting down, I have to:
1) check if the thread is doing things
2) stop it if it is
What's an elegant way to do this? The best I can do is some confused thing like:
def cleanup(s...
Hey all, I'm getting an error
OperationalError: (1054, "Unknown column 'XX' in 'where clause'")
Where XX is the value of CLASS in the following code
conn = MySQLdb.connect(host = "localhost",user = "user", passwd = "pass",db = "dbase")
cursor = conn.cursor()
cursor.execute("""SELECT * FROM %s WHERE course =%s AND sec = %s""" % (s...
What is the fastest way to check if a string matches a certain pattern? Is regex the best way?
For example, I have a bunch of strings and want to check each one to see if they are a valid IP address (valid in this case meaning correct format), is the fastest way to do this using regex? Or is there something faster with like string forma...
The file is uploaded through a Django form. The contents of the file need to be saved into a models.TextField(), for editors to review it before publication.
I am already checking UploadedFile.content_type. I have considered using a regular input field, but as the text is going to be quite long, it would be unwieldy for users to cut and...
import ftplib
server = '192.168.1.109'
user = 'bob'
password = 'likes_sandwiches'
box = ftplib.FTP(server)
box.login(user, password)
s = box.mkd('\\a\\this4\\')
box.close()
x = raw_input('done, eat sandwiches now')
This returns:
Traceback (most recent call last):
File "C:\scripts\ftp_test.py", line 25, in
s = box.mkd('\E\thi...
Where should I overwrite method add() for ManyToMany related fields.
Seems like it is not manager 'objects' of my model. Because when we are adding new relation for ManyToMany fields we are not writing Model.objects.add().
So what I need it overwrite method add() of instance. How can I do it?
Edit:
So i know that there is ManyRelate...
Hi everyone,
I am currently using twisted with wsgi. I wrote my own Engine class which powers the backend to all the logic in my application. Is there an easier method that would allow me to do the following?
in run.py
#Django setup
sys.path.append("spontivity_web")
os.environ['DJANGO_SETTINGS_MODULE'] = 'spontivity_web.settings'
from ...
For example using this Wikipedia dump:
http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=lebron%20james&rvprop=content&redirects=true&format=xmlfm
Is there an existing library for Python that I can use to create an array with the mapping of subjects and values?
For example:
{height_ft,6},{nation...
Ok I have had a problem expressing my problems with the code I am working on without dumping a ton of code; so here is what it would be synchronously (instead of asking it from the view of it being async).
Also for classes when should a variable be accessed through a method argument and when should it be accessed through a instance var...