Quick question. In my syndication feed framework code,
http://docs.djangoproject.com/en/dev/ref/contrib/syndication/
what is the best way to get access to the session? I don't have
access to the request, and I can't use
from django.contrib.sessions.backends.db import SessionStore
as I don't know the session ID, but I need to a...
im spawning a script that runs for a long time from a web app like this:
os.spawnle(os.P_NOWAIT, "../bin/producenotify.py", "producenotify.py", "xx",os.environ)
the script is spawned successfully and it runs, but till it gets over i am not able to free the port that is used by the web app, or in other words i am not able to restart th...
Hi, I would like to know how to retrieve all results from each <p> tag.
import re
htmlText = '<p data="5" size="4">item1</p><p size="4">item2</p><p size="4">item3</p>'
print re.match('<p[^>]*size="[0-9]">(.*?)</p>', htmlText).groups()
result:
('item1', )
what I need:
('item1', 'item2', 'item3')
...
I'm interested in syntax highlighting in a Cocoa TextView.
I found several resources:
approach with flex, via a flex pattern matched against textStorageDidProcessEditing
in a TextView delegate. In this approach the whole string get parsed on each input event, hence performance degrades.
CocoaDev has an own page on the topic of syntax ...
Hi guys,
I know this has been asked before but there is really not a clear answer. My problem is I built a file upload script for GAE and only found out after, that you can only store files up to aprox. 1MB in the data store. I can stop you right here if you can tell me that if I enable billing the 1MB limit is history but I doubt it.
I...
How can I create PyGTK pixmaps with one pixel value set to transparent? I know it has something to do with creating a pixmap of depth 1 and setting it as a mask, but all I find is that it either does nothing or totally erases my pixmap when drawn. At the moment, I make a pixmap with
r = self.get_allocation()
p1 = gtk.gdk.Pixmap(self.win...
I am using lxml to manipulate some existing XML documents, and I want to introduce as little diff noise as possible. Unfortunately by default lxml.etree.XMLParser doesn't preserve whitespace before or after the root element of a document:
>>> xml = '\n <etaoin>shrdlu</etaoin>\n'
>>> lxml.etree.tostring(lxml.etree.fromstring(xml))
'<e...
I'm dabbling in clojure and am having a little trouble trying to determine the clojure (and / or Lisp) equivalent of this common python idiom.
The idiom is that at the bottom of a python module there is often a bit of test code, and then a statement which runs the code, for example:
# mymodule.py
class MyClass(object):
"""Main logi...
I am working on a Python project that includes a lot of simple example scripts to help new users get used to the system. As well as the source code for each example, I include the output I get on my test machine so users know what to expect when all goes well.
It occured to me that I could use this as a crude form of unit testing. Aut...
Is there a way to return a list of all the subdirectories in the current directory in python?
I know you can do this with files, but I need to get the list of directories instead.
...
I'm fairly new to using relational databases, so I prefer using a good ORM to simplify things. I spent time evaluating differing Python SQL libraries and I think SQLAlchemy is what I need. However, I've come to a mental dead end. I need to create a new table to go along with each instance of a player I create in my app's player table....
I have been in love with zsh for a long time, and more recently I have been discovering the advantages of the ipython interactive interpreter over python itself. Being able to cd, to ls, to run or to ! is indeed very handy. But now it feels weird to have such a clumsy shell when in ipython, and I wonder how I could integrate my zsh and m...
So i've followed the docs on this page:
http://docs.python.org/library/ftplib.html#ftplib.FTP.retrbinary
And maybe i'm confused just as to what 'retrbinary' does...i'm thinking it retrives a binary file and from there i can open it and write out to that file.
here's the line that is giving me problems...
ftp.retrbinary('RETR temp.txt'...
Possible Duplicate:
Should I learn Ruby or Python?
Hi guys. I am a PHP developer so, mainly a web developer, and I'm used to work with MVC. I use CakePHP, which is a powerful PHP framework to develop web apps and such.
I'm comming from the web scene and I really want to keep my work on the web but I also would like to learn a n...
Hi,
I have a mosquito problem in my house. This wouldn't usually concern a programmers' community; However, I've seen some devices that claim to deter these nasty creatures by playing a 17Khz tone. I would like to do this using my laptop.
One method would be creating an MP3 with a a single, fixed-frequency tone (This can easily done by...
I want to launch a background Python job from a bash script and then gracefully kill it with SIGINT. This works fine from the shell, but I can't seem to get it to work in a script.
loop.py:
#! /usr/bin/env python
if __name__ == "__main__":
try:
print 'starting loop'
while True:
pass
except KeyboardIn...
I have a list of items (which are HTML table rows, extracted with Beautiful Soup) and I need to iterate over the list and get even and odd elements (I mean index) for each loop run.
My code looks like this:
for top, bottom in izip(table[::2], table[1::2]):
#do something with top
#do something else with bottom
How to make this...
I have a list of dictionaries, e.g:
dictList = [
{'a':3, 'b':9, 'c':4},
{'a':9, 'b':24, 'c':99},
{'a':10, 'b':23, 'c':88}
]
All the dictionaries have the same keys e.g. a, b, c. I wish to create a single dictionary with the same keys where the values are the sums of the values with the same keys from all the dictionaries i...
I'm using Python and its MySQLdb module to import some measurement data into a Mysql database. The amount of data that we have is quite high (currently about ~250 MB of csv files and plenty of more to come).
Currently I use cursor.execute(...) to import some metadata. This isn't problematic as there are only a few entries for these.
Th...
I have a task to download Gbs of data from a website. The data is in form of .gz files, each file being 45mb in size.
The easy way to get the files is use "wget -r -np -A files url". This will donwload data in a recursive format and mirrors the website. The donwload rate is very high 4mb/sec.
But, just to play around I was also using p...