I am trying to use Django sitemaps.
class BlogSiteMap(Sitemap):
"""A simple class to get sitemaps for blog"""
changefreq = 'hourly'
priority = 0.5
def items(self):
return Blog.objects.order_by('-pubDate')
def lastmod(self, obj):
return obj.pubDate
My problem is..I wanted to set the priority of f...
I want to have a JSON object with the value of an attribute as a string with the character " .
For example
{
"Dimensions" : " 12.0" x 9.6" "
}
Obviously this is not possible. How do I do this?
With python.
...
Hello
My adventures in python continues and favorite books are silent again. Python
offers a build-in waiy to test if a variable is inside an iterable object,
using 'in' keyword:
if "a" in "abrakadabra" :
print "it is definitely here"
But is it possible to test if more than one item is in list (any one)?
Currently, i'm using syntax...
I am working on some Python socket code that's using the socket.fromfd() function.
However, this method is not available on all platforms, so I am writing some fallback code in the case that the method is not defined.
What's the best way to determine if a method is defined at runtime? Is the following sufficient or is there a better id...
I'm working on a mod_wsgi script.. at the beginning is:
sys.path.extend(map(os.path.abspath, ['/media/server/www/webroot/']))
But I've noticed, that every time I update the script the sys.path var keeps growing with duplicates of this extension:
['/usr/lib64/python25.zip'
'/usr/lib64/python2.5'
'/usr/lib64/python2.5/plat-linux2'
'/us...
Im using appengine and the appenginepatch (so my issue could be related to that)
I have set up a model with a property that has several choices but when trying to display on a form or via admin interface I am getting an error:
Property mode is 'o'; must be one of (('s', 'Single'), ('m', 'Multi'), ('o', 'Ordered'))
This is my code...
A mysql database table has a column whose datatype is time ( http://dev.mysql.com/doc/refman/5.0/en/time.html ). When the table data is accessed, Python returns the value of this column as a datetime.timedelta object. How do I extract the time out of this? (I didn't really understand what timedelta is for from the python manuals).
E.g. ...
I wish to do this but for a dictionary:
"My string".lower()
Is there a built in function or should I use a loop?
...
The host I'm considering for hosting a Django site has mod_python installed, but does not have Django. Django's INSTALL file indicates that I can simply copy the django directory to Python's site-packages directory to install Django, so I suspect that it might be possible to configure Python / mod_python to look for it elsewhere (namely ...
Is there a far shorter way to write the following code?
my_string = my_string.replace('A', '1')
my_string = my_string.replace('B', '2')
my_string = my_string.replace('C', '3')
my_string = my_string.replace('D', '4')
my_string = my_string.replace('E', '5')
Note that I don't need those exact values replaced, I'm simply looking for a way...
If Python had a macro facility similar to Lisp/Scheme (something like MetaPython), how would you use it?
If you are a Lisp/Scheme programmer, what sorts of things do you use macros for (other than things that have a clear syntactic parallel in Python such as a while loop)?
...
Hello Everyone !
Well ... I am writing an IRC bot in python.
I wish to make stand-alone binaries for Linux and windows of it.
And mainly i wish that when the bot initiates .. the console window should hide and the user should not be able to see the window.
What can I do for that ?
The python way will be better.
...
Why is :memory: in sqlite so slow?
I've been trying to see if there are any performance improvements gained by using in-memory sqlite vs. disk based sqlite. Basically I'd like to trade startup time and memory to get extremely rapid queries which do not hit disk during the course of the application.
However, the following benchmark giv...
I need to send email in delbian linux. How to send? I run my server on 256 MB linux box and I heard postfix and sendmail is overkill.
Recently I came across the ssmtp, that seems to be an executable, needs to be executed as a process and called through python using os modules.
alternatively, python already provides smtplib which is wor...
I am trying to work out how to draw the dragons curve, with pythons turtle using the An L-System or Lindenmayer system. I no the code is something like
the Dragon curve; initial state = ‘F’, replacement rule – replace ‘F’ with ‘F+F-F’, number of replacements = 8, length = 5, angle = 60
But have no idea how to put that into code.
...
I have a Django website in which I want site administrators to be able to edit rich content.
Suppose we're talking about an organizational info page, which might include some pictures, and some links, where the page is not as structured as a news page (which updates with news pieces every few days), but still needs the ability to be easi...
Given the absence of a Windows fork() call, how's the multiprocessing package in Python 2.6 implemented under Windows? On top of Win32 threads or some sort of fake fork or just compatibility on top of the existing multithreading?
...
I have written a script in python that uses cookies and POST/GET. I also included proxy support in my script. However, when one enters a dead proxy proxy, the script crashes. Is there any way to check if a proxy is dead/alive before running the rest of my script?
Furthermore, I noticed that some proxies don't handle cookies/POST headers...
I'm looking for good exif (Exchangeable image file format) manipulation library for python. I prefer flexibility (e.g., ability to retrieve providers' proprietary tags) than processing speed. What would you suggest?
...
I'm trying to make all white pixels transparent using the Python Image Library. (I'm a C hacker trying to learn python so be gentle)
I've got the conversion working (at least the pixel values look correct) but I can't figure out how to convert the list into a buffer to re-create the image. Here's the code
img = Image.open('img.png')
i...