gnomevfs or gio?
For async IO using Python, is it preferable to rely on gio or gnomevfs? Also, which one is more "cross-platform"? ...
For async IO using Python, is it preferable to rely on gio or gnomevfs? Also, which one is more "cross-platform"? ...
The background: I'm building a trie to represent a dictionary, using a minimal construction algorithm. The input list is 4.3M utf-8 strings, sorted lexicographically. The resulting graph is acyclic and has a maximum depth of 638 nodes. The first line of my script sets the recursion limit to 1100 via sys.setrecursionlimit(). The prob...
I have some daemons that use PID files to prevent parallel execution of my program. I have set up a signal handler to trap SIGTERM and do the necessary clean-up including the PID file. This works great when I test using "kill -s SIGTERM #PID". However, when I reboot the server the PID files are still hanging around preventing start-up...
I would appreciate an example on how to perform an async HTTP POST request using Python's GIO binding. Edit: Example sought without using Twisted. ...
For a package of mine, I have a README.rst file that is read into the setup.py's long description like so: readme = open('README.rst', 'r') README_TEXT = readme.read() readme.close() setup( ... long_description = README_TEXT, .... ) This way that I can have the README file show up on my github page every time I commit...
I want to use an alpha mask in OpenGL so that white(1)=visible and black(0)=hidden. So what I do is I write something in the alpha component of the framebuffer using glColorMask(False, False, False, True) (I'm using python, you see) and then draw some geometry above it using blending. But it isn't working: I tried filling the alpha buf...
Hi,I want to batch dowload webpages in one site. There are 5000000 urls links in my 'urls.txt' file. It's about 300M. How make a multi-threads link these urls and dowload these webpages? or How batch dowload these webpages? my ideas: with open('urls.txt','r') as f: for el in f: ##fetch these urls or twisted? Is there a go...
I am having trouble getting this to work correctly (obviously) - I am ALMOST there, and I have a good idea of WHY it is not working - just not sure how to make it work. This is suppose to attempt to read a file into memory, if it fails it goes to the "except" clause of the block of code (that part is 'duh'). The error file prints: "<...
Hey, I've been banging my head for the past two days trying to find out if it's possible to run a python module in C#. The module I'm interested in is Sympy which can be found here http://code.google.com/p/sympy/ (in case anyone's interested). It's a math library, and this one does what I need it to do. I haven't found a C# library which...
It's a little confusing that ZCML registrations for Zope utilities can accept a component or a factory. <utility component=".some.Class" /> versus <utility factory=".some.Factory" /> What is the difference? ...
I'm using the following LaTeX code in a Beamer presentation: \begin{frame} \begin{figure} \centering \tiny \lstset{language=python} \lstinputlisting{code/get_extent.py} \end{figure} \end{frame} Is it possible to select specific lines from my get_extent.py file rather than displaying it all? ...
I have a list of 16 elements [a00,a01,a02,...,a15] and would like to compute a list [b0,b1,b2,b3,b4,b5,b6,b7] where b0 = a00*256+a01 b1 = a02*256+a03 b2 = a04*256+a05 (etc.) what's the easiest way of doing this? (I'm a beginner in python) ...
I'm trying to write some wrapper class or function that allows me to execute some code before and after the wrapped function. float foo(int x, float y) { return x * y; } BOOST_PYTHON_MODULE(test) { boost::python::def("foo", <somehow wrap "&foo">); } Ideally, the wrapper should be generic, working for functions and member fun...
I have a python program with many threads. I was thinking of creating a socket, bind it to localhost, and have the threads read/write to this central location. However I do not want this socket open to the rest of the network, just connections from 127.0.0.1 should be accepted. How would I do this (in Python)? And is this a suitable desi...
Every example I see for sgmlparser involves finding a tag, then finding the attributes/values of the tag. So for it would be the ability to extract 'google.com' out. but i want the data between tags. so if i used sgmlparser, i would look for and extract out everything in that div until it's closing tag. is that the job of sgmlparser, ...
I have 2 dates and I am trying to build labels of an x-axis of a plot. As such, I need a way to take 2 datetime objects, i.e 2009-10-12 00:00:00 and 2009-10-20 00:00:00 and generate a list like so: ["2009-10-12", "2009-10-13", "2009-10-14", ..., "2009-10-19", "2009-10-20"] What libraries should I use to assist? I have a feeling the ...
soup.find("tagName", { "id" : "articlebody" }) Why does this NOT return the <div id="articlebody"> ... </div> tags and stuff in between? It returns nothing. And I know for a fact it exists because I'm staring right at it from soup.prettify() soup.find("div", { "id" : "articlebody" }) also does not work. Edit: There is no answer to...
I've got two different Python extension modules; let's call them A and B. Module A contains a storage class type called container that I want to use within Module B as the return type of a class method. I can't seem to find any documentation on how I'm supposed to do this. I roughly followed this article to create the modules/classe...
I'd like to filter out (mostly one-line) comments from (mostly valid) JavaScript using python's re module. For example: // this is a comment var x = 2 // and this is a comment too var url = "http://www.google.com/" // and "this" too url += 'but // this is not a comment' // however this one is url += 'this "is not a comment' + " and ' ne...
I'm trying to figure out how I can use the type() module to dynamically create a Django model based on existing DB tables without having to either write it out manually or use the manage.py generator to inspect the DB. Reason is my schema changes frequently -- adding new tables, adding/deleting columns, etc. Anyone have a good solution...