Re: wholesale n i k e [...]

2008-07-18 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > [incomplete babbling removed] I guess this guy meant the "whole snake", but messed up his keyboard. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Core Dump - Segmentation Fault -Newbie

2008-07-18 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > Hi - I am very new to python. I get this random core dump and am > looking for a good way to catch the error. I know the function my core > dump occurs. Is there any error catching/handling that I could use in > python? Since you are using Windows, this is somewhat non-t

Re: Core Dump - Segmentation Fault -Newbie

2008-07-18 Thread Stefan Behnel
Doug Morse wrote: > Well, I must be missing something re: why Stefan states that you are using > Windows. I don't see that stated in your original post It's stated in the mail headers of his post, though. That's the problem with newbies - you never know where that stops being right. Stefan -- ht

Re: Best Python packages?

2008-07-19 Thread Stefan Behnel
Iain King wrote: > Well, if you're looking for a list of excellent 3rd party Python > libraries, then I can give you the ones I like and use a lot: [...] > BeautifulSoup : for real-world (i.e. not-at-all-recommendation- > compliant) HTML processing You forgot lxml.html, which is much faster, more

Re: Question

2008-07-19 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > Why is Perl so much better than python? Smart questions deserve smart answers: Yes. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: xpathEval fails for large files

2008-07-22 Thread Stefan Behnel
Fredrik Lundh wrote: > Kanchana wrote: > >> I tried to extract some data with xpathEval. Path contain more than >> 100,000 elements. >> >> doc = libxml2.parseFile("test.xml") >> ctxt = doc.xpathNewContext() >> result = ctxt.xpathEval('//src_ref/@editions') >> doc.freeDoc() >> ctxt.xpathFreeContext

Re: xpathEval fails for large files

2008-07-22 Thread Stefan Behnel
Kanch wrote: > Original file was 18MB, and contained 288328 element attributes for > the particular path. You didn't say how many elements there are in total, but I wouldn't expect that to be a problem, unless you have very little free memory (say, way below 256MB). I just tried with lxml 2.1 and

Re: lxml, comparing nodes

2008-07-23 Thread Stefan Behnel
code_berzerker wrote: > 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. No, because, as you state yourself, equality is not something that everyone defines the same way. > I'd like it > to ignore attribute order and

Re: lxml, comparing nodes

2008-07-24 Thread Stefan Behnel
code_berzerker wrote: > Thanks for help. Thats inspiring, tho not exactly what I need, coz > ignoring document order is requirement (ignoring changes in order of > different siblings of the same type, etc). I plan to try something > like that: > > def xmlCmp(xmlStr1, xmlStr2): > et1 = etree.XML(

Re: lxml, comparing nodes

2008-07-25 Thread Stefan Behnel
code_berzerker wrote: >> 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 pass

Re: lxml, comparing nodes

2008-07-25 Thread Stefan Behnel
code_berzerker wrote: >> 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. Sorry, missed the "let2.remove(foundEl)" line. Stefan -- http://mail.python.org/mailm

Re: xml.dom's weirdness?

2008-07-27 Thread Stefan Behnel
Lie wrote: > Question: Is there a way to list loaded modules, including those that > aren't in my namespace? such as sys.modules? Modules are not unloaded automatically just because you do not use them yourselves. If the module is imported for whatever reason by whatever other module, it stays al

Re: xml.dom's weirdness?

2008-07-27 Thread Stefan Behnel
Lie wrote: > I'm more concerned about the number of modules imported by making an > error (from 30 on the startup to 187) and the side-effect of making an > error, which makes modules such as xml.*/email.* that previously > doesn't exist get imported out of the blue... Using my system Python (2.5.

Re: Read .txt file like .py file

2008-07-27 Thread Stefan Behnel
King wrote: > I have a text file and contents are: > > Help=""" > Code is written by xteam. > """ > value = 0.0 > > > How do I read this file like python syntax. What I mean is first > readline operation should return complete declaration of 'Help' > variable. If I evaluate this string then it s

Re: SWIG and char* newb questions :)

2008-07-29 Thread Stefan Behnel
code_berzerker wrote: > 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 :) Have you considered using Cython? It's almost Python, but it compiles to C code for a Python extension module and even lets you call C func

Re: elementtree and rounding questions

2008-07-29 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > > > > > > > > > > > >name="Courier">text > >

Re: Is it possible to consume UTF8 XML documents using xml.dom.pulldom?

2008-07-30 Thread Stefan Behnel
Simon Willison wrote: > Follow up question: what's the best way of incrementally consuming XML > in Python that's character encoding aware? iterparse(), as implemented in (c)ElementTree and lxml. Note that ElementTree and cElementTree are part of Python 2.5, in the xml.etree package. > I have a

Re: Python parsing iTunes XML/COM

2008-07-30 Thread Stefan Behnel
william tanksley wrote: > Okay, so you decode to go from raw > byes into a given encoding, and you encode to go from a given encoding > to raw bytes. No, decoding goes from a byte sequence to a Unicode string and encoding goes from a Unicode string to a byte sequence. Unicode is not an encoding.

Re: Unicode characters, XML/RSS

2008-07-30 Thread Stefan Behnel
Adam W. wrote: > File "C:\Python25\lib\xml\sax\expatreader.py", line 207, in feed > self._parser.Parse(data, isFinal) > File "C:\Users\Adam\Desktop\Rev3 DL\XMLWorkspace.py", line 51, in > characters > self.data.append(string) > UnicodeEncodeError: 'ascii' codec can't encode character u'

Re: Python parsing iTunes XML/COM

2008-07-30 Thread Stefan Behnel
william tanksley wrote: > william tanksley <[EMAIL PROTECTED]> wrote: >> I'm still puzzled why I'm getting some non-Unicode out of an >> ElementTree's text, though. > > Now I know. > > Okay, my answer is that cElementTree (in Python 2.5) is simply > deranged when it comes to Unicode. It assumes e

Re: Python parsing iTunes XML/COM

2008-07-31 Thread Stefan Behnel
william tanksley wrote: > I didn't > pass a string. I passed a file. It didn't error out; instead, it > produced bytestring-encoded output (not Unicode). >From my experience (and from the source code I have seen so far), ElementTree does not return UTF-8 encoded strings at the API level. Can you p

Re: Multiline text in XML file

2008-08-02 Thread Stefan Behnel
King wrote: > Is there any other way to define multiline text in a XML file: > > > Yes, without the CDATA, for example. XML doesn't treat line ending characters any different from other characters. I have no idea what you are trying to achieve since you didn't tell us (and this newsgroup seems

Re: Wrapping C with Python

2008-08-04 Thread Stefan Behnel
Anish Chapagain wrote: > I tried wrapping a simple C code suing SWIG to Python, but am having > problem, Try Cython. It's a Python-like language between Python and C that compiles to C code. It makes it very easy to call into C functions and to hide them behind a nice Python module. http://cython

Re: Parsing of a file

2008-08-06 Thread Stefan Behnel
Shawn Milochik wrote: >> I would like to parse this file by extracting the field id, ra, dec and mjd >> for each line. It is >> not, however, certain that the width of each value of the field id, ra, dec >> or mjd is the same >> in each line. Is there a way to do this such that even if there was a

Re: benchmark

2008-08-06 Thread Stefan Behnel
Jack wrote: > I know one benchmark doesn't mean much but it's still disappointing to see > Python as one of the slowest languages in the test: > > http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-python-ruby-jython-jruby-groovy/ > Just ignore that. If the code had been desig

Re: how to find out if an object is a class?

2008-08-07 Thread Stefan Behnel
Ben Finney wrote: > szczepiq writes: > >> Pardon me for most likely a dummy question but how do I find out if >> an object is a class? > > Presumably you want to know whether it's a class in order to use it > for instantiating it. It is usually more Pythonic to use the object as > intended, and a

Re: how to find out if an object is a class?

2008-08-08 Thread Stefan Behnel
Miles wrote: > On Fri, Aug 8, 2008 at 2:31 AM, Stefan Behnel wrote: >> I recently had the reverse case that a (stupidly implemented) extension >> module >> required a callback function and I wanted to pass a function wrapped in a >> wrapper object. That failed, because

Re: how to find out if an object is a class?

2008-08-09 Thread Stefan Behnel
Steven D'Aprano wrote: > On Fri, 08 Aug 2008 16:38:14 +0200, Stefan Behnel wrote: >> Miles wrote: >>> On Fri, Aug 8, 2008 at 2:31 AM, Stefan Behnel wrote: >>>> I recently had the reverse case that a (stupidly implemented) >>>> extension module requ

Re: Replace value of node using getElementsByTagName

2008-08-10 Thread Stefan Behnel
Ouray Viney wrote: > Is there an easy way to replace the node value of ? Perhaps I am > trying to use the wrong python XML library? Looks like it. Try ElementTree. from xml.etree import ElementTree tree = ElementTree.parse("yourfile.xml") for ib in tree.findall("//ib"): ib.te

Re: parsing XSD

2008-08-10 Thread Stefan Behnel
Hi, quite a lengthy mail for four lines of content. I guess there was no space left to say "hi"? Spitfire wrote: > I'm trying to use xml.dom.minidom parser to parse a XML schema file. > And, when I invoke 'childNodes' on the root element (schema) I get all > the nodes defined under it, instead of

Re: Replace value of node using getElementsByTagName

2008-08-10 Thread Stefan Behnel
Ouray Viney wrote: > In your example you show: > > ib.text = calculate_new_value(ib.text) > > I don't know what calculate_new_value() represents. It's meant as pseudo-code. Just take the function name literally and replace it by something that gives you the value you want to assign (as you alrea

Re: Wouldn't it be nice if this worked?

2008-08-10 Thread Stefan Behnel
Suresh V. wrote: > class A: > def add(self, x, y): > return x+y > > class B: > pass > > B.add = A.add > > print B().add(1, 2) <- gives TypeError: unbound method add() must >be called with A instance as first argument Works for me: Python 3.0b2

Re: dynamically creating html code with python...

2008-08-11 Thread Stefan Behnel
Hi, [EMAIL PROTECTED] wrote: > how can I combine some dynamically generated html code (using python) with > the output of a urllib.openurl() call? Why reinvent the wheel? Try one of the existing web frameworks. There may be a learning curve for most of them, but you may also end up doing things t

Re: splitting an XML file on the basis on basis of XML tags

2008-04-06 Thread Stefan Behnel
[EMAIL PROTECTED] schrieb: > Hi all, > > i have an XML file with the following structure:: > > > -| > | > | > . | > . | > constitutes one record. > . | > . | > . | > | > | > | > > .

Re: Parsing HTML?

2008-04-06 Thread Stefan Behnel
Benjamin wrote: > I'm trying to parse an HTML file. I want to retrieve all of the text > inside a certain tag that I find with XPath. The DOM seems to make > this available with the innerHTML element, but I haven't found a way > to do it in Python. import lxml.html as h tree = h.parse("s

Re: html DOM

2008-04-06 Thread Stefan Behnel
Sam the Cat wrote: > Is there a package that would allow me the same or similar functionality > for modifying html code via the DOM model as I have in JavaScript ? I'd > like to parse an html file, then modify it and save the result. I am > not trying to do this online, rather I would like to do

Re: How to get an XML DOM while offline?

2008-04-06 Thread Stefan Behnel
william tanksley wrote: > I want to parse my iTunes Library xml. All was well, until I unplugged > and left for the train (where I get most of my personal projects > done). All of a sudden, I discovered that apparently the presence of a > DOCTYPE in the iTunes XML makes xml.dom.minidom insist on ac

Re: splitting an XML file on the basis on basis of XML tags

2008-04-07 Thread Stefan Behnel
bijeshn wrote: > the extracted files are to be XML too. ijust need to extract it raw > (tags and data just like it is in the parent XML file..) Ah, so then replace the "print tostring()" line in my example by ET.ElementTree(element).write("outputfile.xml") and you're done. Stefan -- http:/

Re: Dependency Queue

2008-04-07 Thread Stefan Behnel
Carl Banks wrote: > I'm looking for any information about a certain kind of dynamic data > structure. Not knowing if it has some well-known name that I could > have Googled, I'll just call it a dependency queue. It's like a > priority queue except instead of a strict ordering of items by > priori

Re: Stripping scripts from HTML with regular expressions

2008-04-09 Thread Stefan Behnel
Michel Bouwmans wrote: > I'm trying to strip all script-blocks from a HTML-file using regex. You might want to take a look at lxml.html instead, which comes with an HTML cleaner module: http://codespeak.net/lxml/lxmlhtml.html#cleaning-up-html Stefan -- http://mail.python.org/mailman/listinfo/py

Re: [lxml-dev] CDATA and lxml

2008-04-11 Thread Stefan Behnel
Stefan Behnel wrote: > It's not as trivial as it sounds. Removing the CDATA sections in the parser is > just for fun. ... *not* just for fun ... obviously ... Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Stripping scripts from HTML with regular expressions

2008-04-11 Thread Stefan Behnel
Michel Bouwmans wrote: > I don't think HTMLParser was doing anything wrong here. I needed to parse a > HTML document, but it contained script-blocks with document.write's in > them. I only care for the content outside these blocks but HTMLParser will > choke on such a block when it isn't encapsulat

Re: CDATA and lxml

2008-04-11 Thread Stefan Behnel
Silfheed wrote: > So first off I know that CDATA is generally hated and just shouldn't > be done, but I'm simply required to parse it and spit it back out. > Parsing is pretty easy with lxml, but it's the spitting back out > that's giving me issues. The fact that lxml strips all the CDATA > stuff

Re: [lxml-dev] CDATA and lxml

2008-04-11 Thread Stefan Behnel
Hi again, Stefan Behnel wrote: > Silfheed wrote: >> So first off I know that CDATA is generally hated and just shouldn't >> be done, but I'm simply required to parse it and spit it back out. >> Parsing is pretty easy with lxml, but it's the spitting back out &

Re: codec for html/xml entities!?

2008-04-18 Thread Stefan Behnel
Martin Bless wrote: > What's a good way to encode and decode those entities like € or > € ? Hmm, since you provide code, I'm not quite sure what your actual question is. So I'll just comment on the code here. > def entity2uc(entity): > """Convert entity like { to unichr. > > Return (re

Re: Installing BeautifulSoup with easy_install (broken?)

2008-04-18 Thread Stefan Behnel
John Nagle wrote: >easy_install usually seems to make things harder. > >BeautifulSoup is one single .py file. That's all you need. > Everything else is excess baggage. I wouldn't call the installation of a single module Python package a good example for the "usual" case. Stefan -- http:

Re: codec for html/xml entities!?

2008-04-20 Thread Stefan Behnel
Martin Bless wrote: > [Stefan Behnel] wrote & schrieb: >>> def entity2uc(entity): >>> """Convert entity like { to unichr. >>> >>> Return (result,True) on success or (input string, False) >>> otherwise. Example: >

Re: Conditional for...in failing with utf-8, Spanish book translation

2008-04-21 Thread Stefan Behnel
Hunter wrote: > I've narrowed the problem down to a simple test program. Check this out: > > --- > > # -*- coding: utf-8 -*- > > acceptable = "abcdefghijklmnopqrstuvwxyzóíñú" # this line will work > acceptable = "abcdefghijklmnopqrstuvwxyzóíñúá" # this line won't [bad words stripped] this shou

Re: Elementtree find problem

2008-04-21 Thread Stefan Behnel
Mike Slinn wrote: > The following short Python program parses a KML file and displays the > names of all Marks and Routes: > > from elementtree.ElementTree import ElementTree > tree = ElementTree(file='test.kml') > kml = tree.getroot() > ns = 'http://earth.google.com/kml/2.1' > for folder in kml.f

Re: py3k concerns. An example

2008-04-21 Thread Stefan Behnel
Gabriel Genellina wrote: > You have plenty of time to evaluate alternatives. Your code may become > obsolete even before 3.3 is shipped. Sure, and don't forget to save two bytes when storing the year. ;) Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: py3k concerns. An example

2008-04-22 Thread Stefan Behnel
Gabriel Genellina wrote: >> Has the standard library changed that much? I thought was it mainly the >> deletion of old seldom used modules that happens in new releases anyways. > > *and* renaming of old module names that don't follow PEP8, and merging > others into packages for better structure.

Re: Java or C++?

2008-04-22 Thread Stefan Behnel
hdante wrote: > 6. If you just want to speed-up your python programs or offer some > special, system-specific or optimized behavior to your python > applications, or you just want to complement your python knowledge, > learn C. "Learn C", ok, but then go and use Cython instead. Stefan -- http://

Re: Remove multiple inheritance in Python 3000

2008-04-22 Thread Stefan Behnel
GD wrote: > Please remove ability to multiple inheritance in Python 3000. I'm so happy *that's* a dead parrot, all right. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Remove multiple inheritance in Python 3000

2008-04-22 Thread Stefan Behnel
GD wrote: > Please remove ability to multiple inheritance in Python 3000. > > Multiple inheritance is bad for design, rarely used and contains many > problems for usual users. Ah, one more: "doctor, when I do this, it hurts!" - "then don't do that!" Stefan -- http://mail.python.org/mailma

Re: DTD validation and xmlproc

2008-04-23 Thread Stefan Behnel
mmm wrote: > I am willing to learn and use new xml procedures, but I found nothng > pre-written to validate agaisnt a given DTD file. > > Any advice would be welcome, even a good tutorial on XML validation > usiog Python. Regarding that part, try lxml. http://codespeak.net/lxml http://codespeak.

Re: convert xhtml back to html

2008-04-24 Thread Stefan Behnel
Tim Arnold wrote: > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to > create CHM files. That application really hates xhtml, so I need to convert > self-ending tags (e.g. ) to plain html (e.g. ). This should do the job in lxml 2.x: from lxml import etree tr

Re: convert xhtml back to html

2008-04-24 Thread Stefan Behnel
bryan rasmussen top-posted: > On Thu, Apr 24, 2008 at 9:55 PM, Stefan Behnel <[EMAIL PROTECTED]> wrote: >> from lxml import etree >> >> tree = etree.parse("thefile.xhtml") >> tree.write("thefile.html", method="html") >

Re: Can you recommend a book?

2008-04-25 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > Hello all, I learned Python with the book "Programming Python" by John > Zelle. But today this book is a little bit old. My Python is some kind > old. I need a book that will help me brush my style and keep me up to > date. I would like one with practical examples. > > C

Re: is there a python equivalent for this tool?

2008-04-25 Thread Stefan Behnel
Jorge Vargas wrote: > Dear python users, do you know of a tool like this that is written in python? > > http://code.google.com/p/css-redundancy-checker/ > > in case you where wondering I just don't want to have the ruby > dependency on my python proyects. This comes to mind: http://code.google.

Re: Parsing HTML?

2008-04-26 Thread Stefan Behnel
Benjamin wrote: > On Apr 6, 11:03 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote: >> Benjamin wrote: >>> I'm trying to parse an HTML file. I want to retrieve all of the text >>> inside a certain tag that I find with XPath. The DOM seems to make >>> t

Re: Sphinx 0.2 released

2008-04-28 Thread Stefan Behnel
Hi Georg, Georg Brandl wrote: > I'm pleased to announce the release 0.2 of Sphinx, the Python documentation > generation tool. There were some intermediate smaller releases in the 0.1 > series, but for 0.2 there are quite a lot new features and fixes. > > What is it? > === > > Sphinx is

Re: Do you know of a much simpler way of writing a program that writes a program?

2008-05-02 Thread Stefan Behnel
mcse jung wrote: > Here is asample program that writes a program and then executes it. > Do you knowof a much simpler way of writing a program that writes a program? I'm not quite sure what you are trying to achieve here, but I bet there is a simpler way to do it than by generating a script. You

Re: Error handling in SAX

2008-05-03 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > (this is a repost, for it's been a while since I posted this text via > Google Groups and it plain didn't appear on c.l.py - if it did appear > anyway, apols) It did, although some people have added google groups to their kill file. > So I set out to learn handling thr

Re: xml.etree Syntax of path?

2008-05-09 Thread Stefan Behnel
Thomas Guettler wrote: > I think the documentation of xml.etree is missing something[1]. > > {{{ > find(path) > Finds the first toplevel element with given tag. Same as > getroot().find(path). path is the element to look for. > }}} > > According to the source etree has limited support for xpa

Re: source beautifier

2008-05-09 Thread Stefan Behnel
Marco Mariani wrote: > Is there a program (free, payware, whatever) like polystyle for > linux/python? > > http://www.polystyle.com/features/python-beautifier.jsp > > I've never used it, but the example is quite clear. I tend to believe that running these tools on some average Python code would

Re: A question about python and xml

2008-05-09 Thread Stefan Behnel
Holden wrote: > I want to make a web site that uses the python programming > language which I am VERY new at. This website would store simple data > such as names in a form. At first I wanted to use mysql to store the > data but I want to export the data using xml. > > So say if a user logged in t

Re: PyXml

2008-05-09 Thread Stefan Behnel
Martin v. Löwis wrote: >> Can anyone recommend a Python validating parser that validates vs Xml >> Schema? > > The libxml bindings for Python can do that. ... although the OP will likely prefer using lxml, where it's three lines of Python (ok, plus an import), compared to quite a bit of code in t

Re: HTML Tables

2008-08-19 Thread Stefan Behnel
Amie wrote: > Thanks for your help so far. Ok here's a scenario: I have to create a > site that displays 34 html tables. > In each of these tables the following information has to be displayed: > logo (image), site name, date, time. > Remember: in all of these 34 tables. the information displayed

Re: xpath questions...

2008-08-23 Thread Stefan Behnel
Hi, this is totally not Python related, so this is the wrong list. bruce wrote: > form action='foo' name='cat' > > i'm curious, is there a way to select an attribute, only if another > attribute in the element is set to a given value?? > > something like > //form/[EMAIL PROTECTED]'foo'[EMAI

Re: Python 3000 C API Changes

2008-08-23 Thread Stefan Behnel
rahul wrote: > I am trying to find out what Python C APIs are changing from Python > 2.5 to Python 3.0 but there does not seem to be a single list of > changes (or at least google is not finding one). > If someone knows about where I should look, please let me know. Check out what Cython does in i

Re: iterparse and unicode

2008-08-23 Thread Stefan Behnel
George Sakkis wrote: > On Aug 21, 1:48 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >> George Sakkis wrote: >>> It's interesting that the element text attributes after a successful >>> parse do not necessarily have the same type, i.e. all be str or all >>> unicode. I ported some text extraction

Re: iterparse and unicode

2008-08-23 Thread Stefan Behnel
George Sakkis wrote: > It seems xml.etree.cElementTree.iterparse() is not unicode aware: > from StringIO import StringIO from xml.etree.cElementTree import iterparse s = u'\u03a0\u03b1\u03bd\u03b1\u03b3\u03b9\u03ce\u03c4\u03b7\u03c2' for event,elem in iterparse(StringIO(s

Re: When I do from lxml import etree I've this error : AttributeError: 'module' object has no attribute 'BytesIO'

2008-08-25 Thread Stefan Behnel
KLEIN Stéphane wrote: > Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) from lxml import etree > Traceback (most recent call last): > File "", line 1, in > File "lxml.etree.pyx", line 40, in lxml.etree (src/lxml/ > lxml.etree.c:119415) > AttributeError: 'module' object has no attribute

Re: python xslt library

2008-08-25 Thread Stefan Behnel
Owen Zhang wrote: > Can anyone recommand the best performance python xslt library? lxml. It's based on libxml2/libxslt. http://codespeak.net/lxml Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: libxml2dom - parsing maligned html

2008-08-26 Thread Stefan Behnel
bruce wrote: > I'm using quick test with libxml2dom > > === > import libxml2dom > > aa=libxml2dom.parseString(foo) > ff=libxml2dom.toString(aa) > > print ff > === > > -- > when i start, foo is: > > > > > > > > . > . > . > > >

Re: python mechanize/libxml2dom question

2008-09-01 Thread Stefan Behnel
bruce wrote: > i've got the following situation, with the following test url: > "http://schedule.psu.edu/soc/fall/Alloz/a-c/acctg.html#";. > > i can generate a list of the tables i want for the courses on the page. > however, when i try to create the xpath query, and plug it into the xpath > withi

Re: python/xpath question..

2008-09-04 Thread Stefan Behnel
Hi, you should really read about XPath. There are also newsgroups specifically for this topic, please use them. bruce wrote: > in my python, i'm using the xpath function to iterate/parse some html. i can > do something like > > s=d.xpath("//tr/td/text()") > count=len(s) > > and get the number

Re: xml + mmap cross

2008-09-04 Thread Stefan Behnel
castironpi wrote: > Any interest in pursuing/developing/working together on a mmaped-xml > class? Faster, not readable in text editor. Any hints on what you are talking about? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Xpath for HTML processing

2008-09-04 Thread Stefan Behnel
Astley Le Jasper wrote: > Can anyone suggest something inthat can process an XPath like the > following: > > "/html/body/table[2]/tbody/tr/td[5]/table/tbody/tr[3]/td/table[3]/ > tbody/tr[5]/td" [skipping the obvious joke answer to your question] In case you're asking for a tool that can process

Re: python/xpath question..

2008-09-04 Thread Stefan Behnel
Stefan Behnel wrote: > Yes, learn to use XPath, e.g. > > //tr/td[not string()] Oh, well... //tr/td[not(string())] as I said, wrong news group. ;-) Try something like "gmane.text.xml.xpath.general", for example. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: xml + mmap cross

2008-09-04 Thread Stefan Behnel
Hi, this discussion seems pretty much off-topic for a Python list. castironpi wrote: > In an XML file, entries are stored in serial, sort of like this. > > AAA BBB CCC DDD > > Or more recognizably, > > somethingsomething > > Point is, to change something to something else, you > have to recop

Re: "Full" element tag listing possible with Elementtree?

2008-09-05 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > I have the unenviable task of turning about 20K strangely formatted > XML documents from different sources into something resembling a > clean, standard, uniform format. I like Elementtree and have been > using it to step through the documents to get a feel for their > s

Re: Extract Information from Tables in html

2008-09-05 Thread Stefan Behnel
Hi, Jackie Wang wrote: > Here is a html code: > > > > Premier Community Bank of Southwest Florida > > Fort Myers, FL > > > > My question is how I can extract the strings and get the results: > Premier Community Bank of Southwest Florida; Fort Myers, FL Use lxml.h

Re: delete an HTML tag while keeping its content

2008-09-06 Thread Stefan Behnel
[fixing the subject appropriately] Jackie Wang wrote: > How should I delete the 'font' tags while keeping the content inside? Amongst many other goodies for working with HTML, the Elements in lxml.html have a ".drop_tag()" method specifically for that purpose. http://codespeak.net/lxml/ Stefan

Re: Is there a SOAP module that can do this...?

2008-09-11 Thread Stefan Behnel
thebjorn wrote: > I've been trying to use SOAPpy and ZSI (with and without the use of > wsdl2py) to communicate with a SOAP server (looks like it's a WebLogic > server(?) in front of some enterprise java bean) and not having much > luck. Have you tried using soaplib? I find it very usable and from

Re: lxml build error in sun

2008-09-13 Thread Stefan Behnel
Owen Zhang wrote: > I am trying to build lxml package in SunOS 5.10. I got the following > errors. Could you report this on the lxml mailing list? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: ElementTree oddities

2008-09-16 Thread Stefan Behnel
Mark Thomas wrote: > here's how you would do it in lxml (http://codespeak.net/ > lxml/index.html), a library which supports XPath: > > from lxml import etree > tree = etree.fromstring('Bar:') > print ' '.join(tree.xpath('//text()')) If you want to use XPath, try this: print tree.xpath('s

Re: Zsi interoperability

2008-09-16 Thread Stefan Behnel
Marco Bizzarri wrote: > On Mon, Sep 15, 2008 at 8:15 PM, Stefan Behnel <[EMAIL PROTECTED]> wrote: >> Mailing List SVR wrote: >>> I have to implement a soap web services from wsdl, the server is >>> developed using oracle, is zsi or some other python library for s

Re: Generating test data from an XML Schema

2008-09-17 Thread Stefan Behnel
Mark Thomas wrote: > On Sep 17, 5:29 am, Jonathan Fine <[EMAIL PROTECTED]> wrote: >> I want to generate test data from an XML schema. I've had a quick look >> at existing tools (such as minixsv and amara) but from what I've seen >> they don't seem to help. > ... >> A tool that provides a nice Pyth

Re: lxml and schema validation

2008-10-03 Thread Stefan Behnel
hrishy wrote: > I am validating a xmlfile against a xsd (My.xsd) but i notice that the xsd > has a include which includes another xsd (My1.xsd) > > I have written a simple program that to validate this > > from lxml import etree > xmlschemadoc=etree.parse("My.xsd") > xmlschema=etree.XMLSchema(xm

Re: lxml and adding a stylesheet

2008-10-03 Thread Stefan Behnel
Sean Davis wrote: > I have an xml document and simply need to add an xml-stylesheet to > it. I am using lxml to parse the xml document and then would like to > insert the xml-stylesheet tag using the etree api. Any suggestions? I assume you are talking about a processing instruction here, not a

Re: lxml question

2008-10-03 Thread Stefan Behnel
Uwe Schmitt wrote: > I have to parse some text which pretends to be XML. lxml does not want > to parse it, because it lacks a root element. > I think that this situation is not unusual, so: is there a way to > force lxml to parse it ? > > My work around is wrapping the text with "..." before > fee

Re: markov query

2006-03-13 Thread Stefan Behnel
Don't know of a Python module (although this doesn't look complex enough for a package anyway...), but kpp9c wrote: > P.S. Does any one know first of all whether these are called markov > tables, transition tables or probability tables? I am not sure i am > referring to this correctly and what the

[ANN] lxml 0.9 is out!

2006-03-20 Thread Stefan Behnel
Hello everyone, after almost five months of hacking, lxml 0.9 has finally seen the light of night. :) http://codespeak.net/lxml/ http://cheeseshop.python.org/pypi/lxml/0.9 """ lxml is a Pythonic binding for the libxml2 and libxslt libraries. It provides safe and convenient access to these librar

Re: How to fork or spawn processes to second processor ?

2006-03-21 Thread Stefan Behnel
Sabre wrote: > how can I spawn or fork a second process onto the second processor of my > dual core server ? Is there a possibility to determin the processor on which > a process shall run ? Hi, from your post it's not clear why you would want to do that or which operating system you are using.

Re: Filling in a tuple from unknown size list

2009-11-27 Thread Stefan Behnel
boblatest, 27.11.2009 13:18: > Here's my question: Given a list of onknown length, I'd like to be > able to do the following: > > (a, b, c, d, e, f) = list > > If the list has fewer items than the tuple, I'd like the remaining > tuple elements to be set to "None". If the list is longer, I'd like

Re: Filling in a tuple from unknown size list

2009-11-27 Thread Stefan Behnel
Mel, 27.11.2009 18:47: > Steven D'Aprano wrote: >> On Fri, 27 Nov 2009 04:18:08 -0800, boblatest wrote: >>> Here's my question: Given a list of onknown length, I'd like to be able >>> to do the following: >>> >>> (a, b, c, d, e, f) = list >>> >>> If the list has fewer items than the tuple, I'd like

Re: Ignoring XML Namespaces with ElementTree

2009-12-03 Thread Stefan Behnel
Pete, 03.12.2009 19:21: > Is there anyway to configure ElementTree to ignore the XML namespace? > For the past couple months, I've been using minidom to parse an XML > file that is generated by a unit within my organization that can't > stick with a standard. This hasnt been a problem until recentl

Re: How to create a docstring for a module?

2009-12-06 Thread Stefan Behnel
Dr. Phillip M. Feldman, 06.12.2009 21:34: > OK. I was able to reproduce the problem. My difficulty was that the command > that I issued initially was "from xyz import *" rather than just "import > xyz". If I say "import xyz", then the docstring is defined; if I say "from > xyz import *", it isn'

Re: C to Python

2009-12-11 Thread Stefan Behnel
Benjamin Peterson, 10.12.2009 20:26: > Emeka writes: >> I am finding it difficult getting my head around PyObject_CallObject(x,y). I > need a gentle and thorough introduction to it. I also need examples. Could > someone come to my need? > > PyObject_CallFunction is probably easier to use. Hmm, I

<    7   8   9   10   11   12   13   14   15   16   >