Re: SWIG and char* newb questions :)

2008-07-29 Thread code_berzerker
Ok I think I got it: PyObject* myFuncXXX(char* p_1, int p_2, char* p_3, int p_4) { int res; char _host[255] = ""; int _port; res = funcXXX(p_1, p_2, p_3, p_4, _host, &_port); PyObject* res1 = PyInt_FromLong(res); PyObject* res2 = PyString_FromStringAndSize(_host, strlen(_host)); Py

SWIG and char* newb questions :)

2008-07-29 Thread code_berzerker
Hi i'm relatively new to Python and my C/C++ knowledge is near to None. Having said that I feel justified to ask stupid questions :) Ok now more seriously. I have question refering to char* used as function parameters to return values. I have read SWIG manual to find best way to overcome that, but

Re: lxml, comparing nodes

2008-07-25 Thread code_berzerker
> Not in your code. > > Stefan Not sure what you mean, but I tested and so far every document with the same order of elements had number of comparisons equal to number of nodes. -- http://mail.python.org/mailman/listinfo/python-list

Re: lxml, comparing nodes

2008-07-25 Thread code_berzerker
> If document order doesn't matter, try sorting the elements of each level in > the two documents by some arbitrary deterministic key, such as (tag name, > text, attr count, whatever), and then compare them in order, instead of trying > to find matches in multiple passes. itertools.groupby() might

Re: lxml, comparing nodes

2008-07-24 Thread code_berzerker
> off the top of my head (untested): > >  >>> def equal(a, b): > ...     if a.tag != b.tag or a.attrib != b.attrib: > ...         return False > ...     if a.text != b.text or a.tail != b.tail: > ...         return False > ...     if len(a) != len(b): > ...         return False > ...     if any(not

Re: lxml, comparing nodes

2008-07-23 Thread code_berzerker
On Jul 23, 6:29 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote: > Your requirements for a single Element are simple enough to write it in three > to five lines of Python code (depending on your definition of equality). > Checking this equality recursively is another two to three lines. Not complex >

lxml, comparing nodes

2008-07-23 Thread code_berzerker
I'd like to know if there is any built in mechanism in lxml that lets you check equality of two nodes from separate documents. I'd like it to ignore attribute order and so on. It would be even better if there was built in method for checking equality of whole documents (ignoring document order). Pl