I need a validated DomTree with DTD (to use getElementById).
Validating and Parsing works, but the dom does't work properly:
from xml.dom import minidom
from xml.dom.pulldom import SAX2DOM
from lxml import etree
import lxml.sax
from StringIO import StringIO
data_string = """\
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE foo [
<!EL...
This might sound really crazy, but still...
For our revamped project site, we want to integrate Trac (as code browser, developer wiki and issue tracker) into the site design. That is, of course, difficult, since Trac is written in Python and our site in PHP. Does anybody here know a way how to integrate a header and footer (PHP) into th...
Given two arrays hashes and table, for each value in hashes I want to store the position of the element at the element's value's offset in the array table. Here is the naïve algorithm:
def insert_n(table,hashes):
for x in xrange(len(hashes)):
table[hashes[x]]=x
This is extremely slow. Psyco helps some here, but hardly.
N...
Is there a way to have iPython automatically reload all changed code? Either before each line is executed in the shell or failing that when it is specifically requested to. I'm doing a lot of exploratory programming using iPython and SciPy and it's quite a pain to have to manually reload each module whenever I change it.
...
Hi, I have some data like this:
data1 = ['Agos', '30490349304']
data2 = ['Desir\xc3\xa9','9839483948']
I'm using an API that expects the data encoded in base64, so what I do is:
data = data1
string = base64.b64encode("Hi, %s! Your code is %s" % (data[0], data[0]))
myXMLRPCCall(string)
Which works fine with data1. With data2 the enc...
Hey, I'm fairly new to python I have this piece of code which stores the birth info to the datastore in Google App Engine. The code works but is it the correct way to do it? Is there a simpler way to do it, to make sure that the key exists before storing it in datastore?
def store_birthinfo(self, user, birthday):
"""
Store birth...
I want to tell my Python threads to yield, and so avoid hogging the CPU unnecessarily. In Java, you could do that using the Thread.yield() function. I don't think there is something similar in Python, so I have been using time.sleep(t) where t = 0.00001. For t=0 there seems to be no effect.
I think that maybe there is something I am not...
EDITED
ALL GREAT COMMENTS - THANK YOU
I started with c++ but as we all know, c++ is a monster. I still have to take it and I do like C++ (it takes programming a step further)
However, currently I have been working with python for a while. I see how you guys can turn some long algorithm into simple one.
I know programming is a progres...
Hello.
I have a QT 4.6 application (C++ language) and i need to add python scripting to it on windows platform. Unfortunately, i never embed python before, and it seems to be a lot of different ways to do so. Can anyone share his wisdom and point me into some articles/documentation i can read to perform a specified task in less painful ...
How can I combine multiple images, such as base image with logo and number of digits images to display graphical counter with pageviews count, updated dynamically?
It should be very fast, with thousands of renders per second. User should see counter image without Javascript and with single img tag.
I prefer to implement that counter wi...
I have an XML file in the following format:
<doc>
<id name="X">
<type name="A">
<min val="100" id="80"/>
<max val="200" id="90"/>
</type>
<type name="B">
<min val="100" id="20"/>
<max val="20" id="90"/>
</type>
</id>
<type...>
</type>
</doc>
I would like to parse this document and build a hash table
{X: ...
hello .. im trying to extract frames from a video .. and i picked ffmpeg ( tell me if you know something better ) for this task
i downloaded it's source .. and i don't know how to use it ?? how do i compile it ??
what is the recommended language for it ?? i know python and C++
please note that i use windows vista 64x .
...
I want to learn Python and Perl, buy I don't know where need I use it.
I can use PHP to build a website or use Java/.Net to build server-side applications or use JavaScript to write dynamic web pages.
Where can I use Python and Perl?
...
Google web APIs have a Python library. Google Alerts has an email and an RSS feed.
Does anyone know of an automated way to add Google Alerts through a web API in Python? That is, without clicking.
Note: the related question doesn't answer the web API question.
...
When storing a time in Python (in my case in ZODB, but applies to any DB), what format (epoch, datetime etc) do you use and why?
...
I don't really have groked how to translate GROUP BY and HAVING to Django's QuerySet.annotate and QuerySet.aggregate. I'm trying to translate this SQL query into ORM speak
SELECT EXTRACT(year FROM pub_date) as year, EXTRACT(month from pub_date) as month, COUNT(*) as article_count FROM articles_article GROUP BY year,month;
which output...
I am trying to install buildbot for my project.
I always run my svn commands with trust-server-cert option. How can I pass that to SVN thru buildbot?
I don't see there is a way for doing that. What is the shortest workaround?
...
I found this and am using it as my base, but it wasn't working right out of the box. My goal is also to treat it as a package instead of a command line utility, so my code changes will reflect that.
class Netcat:
def __init__(self, hostname, port):
self.hostname = hostname
self.port = port
def send(self, content)...
I've read in a text file and converted each line into a list.
using this script:
l = [s.strip().split() for s in open("cluster2.wcnf").readlines()]
How would i go about :
the file it opens is dynamic rather than static? i.e. the user
chooses the file to open.
Select specific lines to read after it has been converted to a list.
assi...
Hi, I have a problem with virtualenv. I use it regulary, I use it on my development machine and on several servers. But on this last server I tried to use i got a problem.
I created a virtualenv with the --no-site-packages argument, and then I installed some python modules inside the virtualenv. I can confirm that the modules is located...