Re: Xml parser

2007-05-26 Thread Stefan Behnel
XiaQ wrote: > You can use DOM > http://diveintopython.org/, Chapter 9 > "ashish" wrote >> Hi All, >> >> I want to know weather is there any api available in python for parsing >> xml(XML parser) >> >> Regards >> Ashish Sure, you can use DOM, but if you want to get real work done with XML, lxml is

Re: expat parser

2007-05-28 Thread Stefan Behnel
Sebastian Bassi wrote: > I have this code: > > import xml.parsers.expat > def start_element(name, attrs): >print 'Start element:', name, attrs > def end_element(name): >print 'End element:', name > def char_data(data): >print 'Character data:', repr(data) > p = xml.parsers.expat.Parser

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-24 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > On Jul 23, 4:46 pm, "Richard Brodie" <[EMAIL PROTECTED]> wrote: >> <[EMAIL PROTECTED]> wrote in message >> >> news:[EMAIL PROTECTED] >> >>> so what's the difference? how comes parsing is fine >>> in the first case but erroneous in the second case? >> You may have guessed

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-24 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: >> How about trying >> root = ElementTree.parse(urlopen(query), encoding ='utf-8') That doesn't work. > this specific thing is not working, however, parsing the url is not > problematic. So you tried parsing the complete XML file and it works? Then it's the way you stri

Re: Any python module for Traversing HTML files

2007-07-24 Thread Stefan Behnel
johnny wrote: > Any python module for navigating and selecting, parsing HTML files? Since you didn't name any specific requirements, consider taking the best one. "lxml.html" provides loads of goodies like Python iterators, XPath or CSS selection for navigation, or a clean() function for removing

Re: Any reason why cStringIO in 2.5 behaves different from 2.4?

2007-07-26 Thread Stefan Behnel
Stefan Scholl wrote: > After an hour searching for a potential bug in XML parsing > (PyXML), after updating from 2.4 to 2.5, I found this one: > > $ python2.5 > Python 2.5 (release25-maint, Dec 9 2006, 14:35:53) > [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)] on linux2 > Type "help", "copyr

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-26 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > On Jul 26, 3:13 pm, John Machin <[EMAIL PROTECTED]> wrote: >> On Jul 26, 9:24 pm, [EMAIL PROTECTED] wrote: >> >>> OK, I solved the problem but I still don't get what went wrong. >>> Solution - use tree builder in order to create the new xml file >>> (previously I was "ma

Re: Any reason why cStringIO in 2.5 behaves different from 2.4?

2007-07-26 Thread Stefan Behnel
Stefan Scholl wrote: > Stefan Behnel <[EMAIL PROTECTED]> wrote: >> Stefan Scholl wrote: >>> Stefan Behnel <[EMAIL PROTECTED]> wrote: >>>> Stefan Scholl wrote: >>>>> Well, http://docs.python.org/lib/module-xml.sax.html is missing

Re: Any reason why cStringIO in 2.5 behaves different from 2.4?

2007-07-26 Thread Stefan Behnel
Stefan Scholl wrote: > Well, http://docs.python.org/lib/module-xml.sax.html is missing > the fact, that I can't use Unicode with parseString(). > > This parseString() uses cStringIO. Well, Python unicode is not a valid *byte* encoding for XML. lxml.etree can parse unicode, if you really want, bu

Re: Any reason why cStringIO in 2.5 behaves different from 2.4?

2007-07-26 Thread Stefan Behnel
Stefan Scholl wrote: > Stefan Behnel <[EMAIL PROTECTED]> wrote: >> Stefan Scholl wrote: >>> Well, http://docs.python.org/lib/module-xml.sax.html is missing >>> the fact, that I can't use Unicode with parseString(). >>> >>> This parseString(

Re: Any reason why cStringIO in 2.5 behaves different from 2.4?

2007-07-26 Thread Stefan Behnel
Stefan Scholl wrote: > Stefan Behnel <[EMAIL PROTECTED]> wrote: >> Stefan Scholl wrote: >>> Stefan Behnel <[EMAIL PROTECTED]> wrote: >>>> Stefan Scholl wrote: >>>>> Stefan Behnel <[EMAIL PROTECTED]> wrote: >>>>>> Ste

Re: Any reason why cStringIO in 2.5 behaves different from 2.4?

2007-07-26 Thread Stefan Behnel
Stefan Scholl wrote: > Stefan Behnel <[EMAIL PROTECTED]> wrote: >> The XML is *not* well-formed if you pass Python unicode instead of a byte >> encoded string. Read the XML spec. > > Pointers, please. There you have it: http://www.w3.org/TR/xml/#charencoding "

Re: Any reason why cStringIO in 2.5 behaves different from 2.4?

2007-07-27 Thread Stefan Behnel
Stefan Scholl schrieb: > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Fri, 27 Jul 2007 06:47:48 +0200, Stefan Scholl wrote: >> >>> Chris Mellon <[EMAIL PROTECTED]> wrote: XML is not a string. It's a specific type of bytestream. If you want to work with XML, then generate well

Re: Removing certain tags from html files

2007-07-27 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > I'm doing a little script with the help of the BeautifulSoup HTML > parser and uTidyLib (HTML Tidy warper for python). > > Essentially what it does is fetch all the html files in a given > directory (and it's subdirectories) clean the code with Tidy (removes > deprecated

Re: Any reason why cStringIO in 2.5 behaves different from 2.4?

2007-07-28 Thread Stefan Behnel
Stefan Scholl wrote: > Chris Mellon <[EMAIL PROTECTED]> wrote: >> On 7/26/07, Stefan Scholl <[EMAIL PROTECTED]> wrote: >>> Chris Mellon <[EMAIL PROTECTED]> wrote: XML is not a string. It's a specific type of bytestream. If you want to work with XML, then generate well-formed XML in the co

Re: Any reason why cStringIO in 2.5 behaves different from 2.4?

2007-07-28 Thread Stefan Behnel
Stefan Scholl wrote: > Chris Mellon <[EMAIL PROTECTED]> wrote: >> On 7/28/07, Stefan Scholl <[EMAIL PROTECTED]> wrote: >>> Just checked on a system without PyXML: xml/sax/__init__.py >>> defines parseString() and uses cStringIO (when available). >>> >>> Python 2.5.1 >>> >> Yes, thats the fixed bug.

Re: Any reason why cStringIO in 2.5 behaves different from 2.4?

2007-07-30 Thread Stefan Behnel
Stefan Scholl wrote: > Michael L Torrie <[EMAIL PROTECTED]> wrote: >> xml.sax's use of parseString() is exactly correct. xml.sax should >> *never* parse python unicode strings as by definition XML must be >> encoded as a *byte stream*, which is what a python string is. > > I don't care about the

Re: Iteration over strings

2007-08-01 Thread Stefan Behnel
> Robert Dailey wrote: >> I have the following code: >> >> str = "C:/somepath/folder/file.txt" >> >> for char in str: >> if char == "\\": >> char = "/" >> >> The above doesn't modify the variable 'str' directly. I'm still pretty new >> to Python so if someone could explain to me why thi

Re: Plain old SAX and minidom useable? But how then?

2007-08-01 Thread Stefan Behnel
Hi, calm down, minidom is not easy to use, but it can solve your problem. Dobedani wrote: > I guess I don't know where to look for the right information. I hope > you guys can help me on the way. I want to retrieve a string from an > XML-file. If Python were to have XPath available, my problem wo

Re: force unicode strings

2007-08-01 Thread Stefan Behnel
Thomas Guettler wrote: > is it possible to force all non ascii strings to be unicode strings > somehow? > > Sometimes I forget that I need to write u'...' if the string contains > an umlaut. I get an exception in django later. But since the > exception does not show the string it is hard to find i

Re: Emacs + python

2007-08-01 Thread Stefan Behnel
Hadron wrote: > Could anyone put me on the right track to developing Python with emacs > please : modes to consider, debugging etc hopefully all within emacs. > > Any help and shared experiences much appreciated. AFAIR, the Python distribution comes with a Python mode for Emacs. Apart from that

Re: How to read information from tables in HTML?

2007-08-03 Thread Stefan Behnel
ZelluX wrote: > I'm confronted with some trouble when dealing with html files. > > The html files contain javascript and some information stored in tables. > And it seems that they're not well-formed, when parsed with minidom, it > will say "mismatched tag". minidom deals with XML. You're trying

Re: Replacing _xmlplus.dom.minidom with xml.dom.minidom

2007-08-03 Thread Stefan Behnel
Robert Rawlins - Think Blue wrote: > Just as a heads up, minidom is pretty inefficient and difficult to work with > too. > > On someone else's advice I switched over to ElementTree and have been really > pleased with the results, its much simpler to work with and more efficient > too. /and/ lxml.

Re: python + XUL

2007-08-11 Thread Stefan Behnel
Madhu Alagu wrote: > Hi > > > > Python + XUL Success Stories > > > > > Thanks > > Madhu Alagu Any chance you forgot to ask a question? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: ElementTree surprise

2007-08-16 Thread Stefan Behnel
Paul Rubin wrote: > Torsten Bronger <[EMAIL PROTECTED]> writes: >>> >> Technically, text is nodes as all other element nodes. In the >> parrot example, there is no empty textnode but no textnode at all. > > That is required by the xml standard? If yes, elementtree is doing > the right thing

Re: Can python threads take advantage of use dual core ?

2007-08-17 Thread Stefan Behnel
Diez B. Roggisch wrote: > nikhilketkar schrieb: >> What are the implications of the Global Interpreter Lock in Python ? >> Does this mean that Python threads cannot exploit a dual core >> processor and the only advantage of using threads is in that >> computation and IO-bound operations can continu

Re: Sorting a list of Unicode strings?

2007-08-19 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > Hey Guys, ... and girls - maybe ... > Maybe I'm missing something fundamental here, but if I have a list of > Unicode strings, and I want to sort these alphabetically, then it > places those that begin with unicode characters at the bottom. That's because "Unicode" is

Re: urllib2.urlopen(url) pulling something other than HTML

2007-08-20 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > I personally think the application itself "feels" more complicated > than it needs to be but its possible that is just my inexperience. I'm > going to do some reading about the HTMLParser module. I'm sure I > could make this spider a bit more functional in the process.

Re: urllib2.urlopen(url) pulling something other than HTML

2007-08-21 Thread Stefan Behnel
Gabriel Genellina wrote: > On 21 ago, 18:36, [EMAIL PROTECTED] (John J. Lee) wrote: >> Gabriel Genellina <[EMAIL PROTECTED]> writes: >> >> [...]> Don't even try to understand it - it's a mess. Use the HTMLParser >>> module instead. >> [...] >> >> Module sgmllib (and therefore module htmllib also) i

Re: ANN: SCF released GPL

2007-08-27 Thread Stefan Behnel
Alex Martelli wrote: > hg <[EMAIL PROTECTED]> wrote: >... >> I am looking for a free subversion server resource to put the code ... >> if you know of any. > > Check out code.google.com -- it has a hosting service for open source > code, too, these days (and it IS subversion). It's Google, tho

Re: ANN: SCF released GPL

2007-08-27 Thread Stefan Behnel
Paul Rubin wrote: > hg <[EMAIL PROTECTED]> writes: >> I am looking for a free subversion server resource to put the code >> ... if you know of any. > > Does it have to be SVN? I think Savannah and Sourceforge both still > use CVS. At least SF has usable Subversion support by now. You can choose

Re: sorting a list of lists

2007-08-27 Thread Stefan Behnel
iapain wrote: >> i would like to sort a list of lists. The list is first sorted on the >> second item in the sub-lists (which I can do), then on the third item >> (which I can't). > > Write a comparator instead of dirty hacks > > mylistoflist.sort(mycomparator) > > def mycomparator(a, b): > #d

Re: replacing xml elements with other elements using lxml

2007-08-29 Thread Stefan Behnel
Ultrus wrote: > I'm attempting to generate a random story using xml as the document, > and lxml as the parser. I want the document to be simplified before > processing it further, and am very close to accomplishing my goal. > Below is what I have so far. Any ideas on how to move forward? > > The g

Re: general function for sorting a matrix

2007-08-29 Thread Stefan Behnel
Xah Lee wrote: [undermotivated blah stripped] don't feed the troll. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: IDE for Python

2007-08-29 Thread Stefan Behnel
Eric CHAO wrote: > I think many python developers don't need such an IDE actually. Just > like Ruby guys, they use a powerful editor, for example, Textmate, > instead of all-in-one IDE. It's quick and direct. True. However, some use neither an editor nor an IDE but Emacs. Stefan -- http://mail.p

Re: replacing xml elements with other elements using lxml

2007-08-30 Thread Stefan Behnel
Ultrus wrote: > Ah! I figured it out. I forgot that the tree is treated like a list. > The solution was to replace the element with the first > child, then use Python's insert(i,x) function to insert elements after > the first one. You could also use slicing, something like: parent[2:3] = c

Re: SAXParseException: not well-formed (invalid token)

2007-08-30 Thread Stefan Behnel
Pablo Rey wrote: > I am getting the following error with a XML page: > >> File "/home/prey/RAL-CESGA/bin/voms2users/voms2users.py", line 69, >> in getItems >> d = minidom.parseString(xml.read()) >> File "/usr/lib/python2.2/site-packages/_xmlplus/dom/minidom.py", >> line 967, in parseSt

Re: Simple elementtree question

2007-08-30 Thread Stefan Behnel
IamIan wrote: > This is in Python 2.3.5. I've had success with elementtree and other > RSS feeds, but I can't get it to work with this format: > > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; > xmlns:dc="http://purl.org/dc/elements/1.1/"; > xmlns:fr="http://ASPRSS.com/fr.html"; >

Re: Simple elementtree question

2007-08-31 Thread Stefan Behnel
IamIan wrote: > Thank you very much! That did it. > > In the source XML tags have rdf:about attributes with the link > to the story, and it was here I planned on grabbing the link and > matching it up with the child text. After seeing the output of > elmenttree's getiterator() though, it now loo

Re: Python object <-> XML

2007-09-03 Thread Stefan Behnel
Samuel wrote: > Say you have the following XML: > > > item 1 > > > item 2 > > > > > my group > > > Is there an easy way (i.e. without writing a sax/dom parser) to load > this into a (number of) Python object(s), manipulate the instance, and > save the result back to XML? Try lx

Re: Python syntax wart

2007-09-08 Thread Stefan Behnel
Marc 'BlackJack' Rintsch wrote: > On Sun, 09 Sep 2007 17:16:05 +1200, Lawrence D'Oliveiro wrote: > >> The one thing I don't like about Python syntax is using backslashes to >> continue lines. Yes, you can avoid them if you can include parentheses >> somehow, but this isn't always possible. >> >> P

Re: Python syntax wart

2007-09-09 Thread Stefan Behnel
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Stefan Behnel wrote: > >> He means he has to use backslashes instead of parentheses here. >> >> Which is not true, you could easily rephrase this as: >> >> fo

Re: Python syntax wart

2007-09-10 Thread Stefan Behnel
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch > wrote: >> And this is also easily written that way in Python if you don't insist on >> the line break after the ``if`` or can live with backslashes. > > Which is precisely the point. This actually sounds somew

Re: XML: SAX and XInclude

2007-09-10 Thread Stefan Behnel
Laurent Pointal wrote: > does anybody know about an XML parser usable with the sax API (xml.sax) > and with XInclude feature support (directly or via hacks). Try lxml.etree. http://codespeak.net/lxml/ http://codespeak.net/lxml/tutorial.html http://codespeak.net/lxml/api.html#xinclude-and-element

Re: Python 3K or Python 2.9?

2007-09-12 Thread Stefan Behnel
Bjoern Schliessmann wrote: >> What does "self" have to do with an object model? It's an >> function/method argument that might as well be hidden in the >> compiler without ever touching the role it has (if not, why?). I >> agree that it's needless noise in a language. > > If this was needless, why

Re: Generating HTML

2007-09-12 Thread Stefan Behnel
Sebastian Bassi wrote: > What are people using these days to generate HTML? I still use > HTMLgen, but I want to know if there are new options. I don't > want/need a web-framework a la Zope, just want to produce valid HTML > from Python. There's also lxml.html, which has straight forward support f

Re: lxml + mod_python: cannot unmarshal code objects in restricted execution mode

2007-09-13 Thread Stefan Behnel
Dmitri Fedoruk wrote: > def extApplyXslt(xslt, data, logger ): > try: > strXslt = urllib2.urlopen(xslt).read() > # i have to read the xslt url to the python string > except urllib2.HTTPError, e: >... > except urllib2.URLError, e: >. >

Re: How use XML parsing tools on this one specific URL?

2007-03-05 Thread Stefan Behnel
[EMAIL PROTECTED] schrieb: > I understand that the web is full of ill-formed XHTML web pages but > this is Microsoft: > > http://moneycentral.msn.com/companyreport?Symbol=BBBY > > I can't validate it and xml.minidom.dom.parseString won't work on it. Interestingly, no-one mentioned lxml so far:

Re: Python object to xml biding

2007-03-05 Thread Stefan Behnel
raf wrote: > I'm looking for a python to XSD/xml biding library to easy handling > this very large protocol spec I need to tackle. I've searched google > quite extensibly and I haven't found anything that properly fits the > bill... I'm mostly interested at the xml -> python and python->xml > marsh

Re: most complete xml package for Python?

2007-03-14 Thread Stefan Behnel
metaperl wrote: > Without even checking them all out, I'm thinking the Amara XML Toolkit > must be the most feature-packed. Please check out lxml before you post FUD like this. http://codespeak.net/lxml/ Regards, Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and XML?

2007-04-14 Thread Stefan Behnel
Leonard J. Reder wrote: > What is the best way to process a Relax NG Schema and auto generate XML > Python parser/generator code? > Any suggestions? Not sure what you mean with "XML Python parser/generator code", but regarding RNG, you should definitely give lxml a try. It may already be what you

Re: XML/encoding/prolog/python hell...

2007-04-14 Thread Stefan Behnel
fscked schrieb: > I am a beginning pythoner and I am having a terrible time trying to > figure out how to do something that (it would seeme to me) should be > fairly simple. > > I have a CSV file of unknown encoding and I need to parse that file to > get the fields <--- DONE > I need to create an

Re: XML/encoding/prolog/python hell...

2007-04-14 Thread Stefan Behnel
with lxml (although untested): fscked wrote: > import os,sys > import csv from lxml.etree import Element, SubElement, ElementTree, tostring > root = Element("{Boxes}boxes") > myfile = open('ClientsXMLUpdate.csv') > csvreader = csv.reader(myfile) > > for row in csvreader: > mainbox = SubElem

Re: Python and XML?

2007-04-15 Thread Stefan Behnel
Leonard J. Reder wrote: > What I as really after though was other possible solutions > like JAX in the Java world or Gnosis in the Python world. > > Something that can take a Relax NG Schema and compile > it into a bunch of parser/generator objects for handling > an XML format. That's why I was a

Re: Standardizing XML

2007-04-15 Thread Stefan Behnel
ZeeGeek wrote: > Is there a module for python to standardize XML? Since MSN Live Space > doesn't use standard XML in the posts, I want to standardize them so > that I can use them elsewhere. Could you give a hint what you mean with "standardize"? What's non standardized XML for you? Stefan -- h

Re: python 2.5 cElementTree entity troubles

2007-09-15 Thread Stefan Behnel
Diez B. Roggisch wrote: > Any suggestions on how to teach the built-in ET-parser entities? As you already do it in your code. http://effbot.org/elementtree/elementtree-xmlparser.htm#tag-ET.XMLParser.entity But I guess your version of cET is just too old. Stefan -- http://mail.python.org/mailma

Re: python 2.5 cElementTree entity troubles

2007-09-15 Thread Stefan Behnel
Stefan Behnel wrote: > Diez B. Roggisch wrote: >> Any suggestions on how to teach the built-in ET-parser entities? > > As you already do it in your code. > > http://effbot.org/elementtree/elementtree-xmlparser.htm#tag-ET.XMLParser.entity Hmmm, I never needed this, but the

Re: find and remove "\" character from string

2007-09-15 Thread Stefan Behnel
Konstantinos Pachopoulos wrote: > i have the following string s and the following code, which doesn't > successfully remove the "\", but sucessfully removes the "\\". > s="Sad\\asd\asd" newS="" for i in s: > ... if i!="\\": > ... newS=newS+i I'm not quite sure what

Re: SVG to raster conversion.

2007-09-16 Thread Stefan Behnel
J. Cliff Dyer wrote: > Does anybody know a good solution (preferably in python) for rasterizing > SVG or other vector graphics. > > I'm thinking something like > > vector_image = SVGFile(path_to_image) > raster_image = vector_image.rasterize(format, (width, height), dpi) > raster_image.write(out_

Re: Extracting xml from html

2007-09-18 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > I am attempting to extract some XML from an HTML document that I get > returned from a form based web page. For some reason, I cannot figure > out how to do this. > Here's a sample of the html: > > > > lots of screwy text including divs and spans > > 1126264 >

Re: Extracting xml from html

2007-09-19 Thread Stefan Behnel
George Sakkis wrote: > Given that you can do in 2 lines what > took you around 15 with lxml, I wouldn't think it twice. Don't judge a tool by beginner's code. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Extracting xml from html

2007-09-19 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > Does this make sense? It works pretty well, but I don't really > understand everything that I'm doing. > > def Parser(filename): It's uncommon to give a function a capitalised name, unless it's a factory function (which this isn't). > parser = etree.HTMLParser() >

Re: lxml codespeak pages empty ?

2007-09-19 Thread Stefan Behnel
Laurent Pointal wrote: > I can no longer get codespeak's lxml page at http://codespeak.net/lxml/ > (get an empty HTML document Transitional//EN">)... > > > Am-I alone in this case ? > Any codespeaker reading ? Hmm, it's working for me... Stefan -- http://mail.python.org/mailman/listinfo/pytho

Re: Extracting xml from html

2007-09-19 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: >>row = tree.find("//Row") >>print row.findtext("primaryowner") >>print row.findtext("customeraddress") > > I tried this your way and Laurent's way and both give me this error: > > AttributeError: 'NoneType' object has no attribute 'findtext' Well, error hand

Re: lxml and identification of elements in source

2007-09-20 Thread Stefan Behnel
Laurent Pointal wrote: > I use lxml to parse a document, modify some elements in the tree, run > xinclude on it (thanks to Stefan Behnel for the pointer), and finally use > the data to feed my sax-aware tool. > > To report warnings/errors to the user (not related to XML itself,

Re: validating parser

2007-09-20 Thread Stefan Behnel
David wrote: > On 9/20/07, Robert Schweikert <[EMAIL PROTECTED]> wrote: >> Is there a Python module which will do XSD validation? > > http://mail.python.org/pipermail/xml-sig/2006-June/011527.html ... of which lxml (i.e. libxml2) is definitely the most standards compliant (and feature rich anyway

Re: newb: BeautifulSoup

2007-09-20 Thread Stefan Behnel
TheFlyingDutchman wrote: > On Sep 20, 8:04 pm, crybaby <[EMAIL PROTECTED]> wrote: >> I need to traverse a html page with big table that has many row and >> columns. For example, how to go 35th td tag and do regex to retireve >> the content. After that is done, you move down to 15th td tag from >>

Re: An Editor that Skips to the End of a Def

2007-09-21 Thread Stefan Behnel
Bjoern Schliessmann wrote: > Lawrence D'Oliveiro wrote: >> After two decades of putting up with vi just to ensure >> compatibility with every proprietary *nix system I might come >> across, let me just say ... >> >> USE EMACS! > > Nah. Use vim. > >> Oh, and >>

Re: An Editor that Skips to the End of a Def

2007-09-21 Thread Stefan Behnel
W. Watson wrote: > Is vim just an editor or is it capable of running and debugging a > program, as well? Depends on how you define an editor. If you take Emacs as example for an editor, then, no, it's not an editor. BTW: >>> (It even gives useful advice on top-posting if you use it as a news >>>

Re: __contains__() : Bug or Feature ???

2007-09-21 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > I need to overload the operator in and let him > return an object ... It seems it is not a > behavior Python expect : > class A: > ...def __contains__(self,a): > ...return 'yop' > ... a=A() print 'toto' in a > True Not sure what you're trying

Re: An Editor that Skips to the End of a Def

2007-09-21 Thread Stefan Behnel
Michael v. Fondern wrote: > (Ctrl-Shift-Down) Is this the opposite of thumbs up, or is it just to suggest that Eclipse can come close to Emacs's usability if you try hard? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: An Editor that Skips to the End of a Def

2007-09-22 Thread Stefan Behnel
W. Watson wrote: > Bruno Desthuilliers wrote: >> W. Watson a écrit : >>> How about in the case of MS Win? >>> >>> Ben Finney wrote: (Please don't top-post. Instead, reply below each point to which you're responding, removing quoted text irrelevant to your response.) >> >> Wayne,

Re: elementtree question

2007-09-24 Thread Stefan Behnel
Tim Arnold wrote: > Hi, I'm using elementtree and elementtidy to work with some HTML files. For > some of these files I need to enclose the body content in a new div tag, > like this: > > >original contents... > > Give lxml.etree (or lxml.html) a try: tree = etree.parse("http://

Re: rules from an xml file

2007-09-24 Thread Stefan Behnel
jonny wrote: > I have a python code that manages some parameters using some variable > rules that may change from day to day. I'd like that the code will > self-modify according to rules parsed from a xml file: > > example: > > > > > > >

Re: Python script to optimize XML text

2007-09-25 Thread Stefan Behnel
Gabriel Genellina wrote: > En Mon, 24 Sep 2007 17:36:05 -0300, Robert Dailey <[EMAIL PROTECTED]> > escribi�: > >> I'm currently seeking a python script that provides a way of >> optimizing out >> useless characters in an XML document to provide the optimal size for the >> file. For example, assume

Re: Google and Python

2007-09-25 Thread Stefan Behnel
Hendrik van Rooyen wrote: > "Nick Craig-Wood" wrote: > >> Passing file descriptors between processes is one of those things I've >> always meant to have a go with, but the amount of code (in Advanced >> Programming in the Unix Environment) needed to implement it is rather >> disconcerting! A pyt

Re: Inserting an element into existing xml file

2007-09-25 Thread Stefan Behnel
Anand wrote: > I'm new to Python. we are using python2.4. > > I wanted to insert an element into an existing xml file. Can anyone > help me with this? > I've seen lxml and elementTree in python2.5 has some API's to insert > into existing xml file. > We cant use python 2.5 due to some limitations.

Re: Python XML API's that preserve XML comments?

2007-09-26 Thread Stefan Behnel
Dan Stromberg wrote: > Are there any python XML parsing API's that preserve comments - Try lxml. http://codespeak.net/lxml > preferrably that come with python 2.5.1? It doesn't come with Python 2.5.1, but it's compatible to ElementTree, which is part of the stdlib. So you can have a fallback t

Re: elementtree question

2007-09-26 Thread Stefan Behnel
Fredrik Lundh wrote: > (this recent lxml habit of using lxml-specific versions of things that > are trivial to do with the standard API is a bit disappointing. kind of > defeats the purpose of having a standard API...) ElementTree is not the only standard API that lxml is following. Another one i

Re: elementtree question

2007-09-26 Thread Stefan Behnel
Tim Arnold wrote: > Thanks for the great answers--I learned a lot. I'm looking forward to the ET > 1.3 version. Note that there is a difference in behaviour, though. lxml.etree forces Elements to be uniquely positioned in a tree, so the code I posted relies on the "side effect" of automatically r

Re: How do I get the value out of a DOM Element

2007-09-27 Thread Stefan Behnel
kj7ny wrote: > I have been able to get xml.dom.minidom.parse('somefile.xml') and then > dom.getElementsByTagName('LLobjectID') to work to the point where I > get something like: [] which I > can get down to but then I > can't find any way to just get the value out from the thing! > > .toxml() ret

Re: How do I get the value out of a DOM Element

2007-09-27 Thread Stefan Behnel
kj7ny wrote: > Forgot to mention I'm using Python 2.4.3. You can install both lxml and ET on Python 2.4 (and 2.3). It's just that ET went into the stdlib from 2.5 on. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Create a string array of all comments in a html file...

2007-10-06 Thread Stefan Behnel
sophie_newbie wrote: > Hi, I'm wondering how i'd go about extracting a string array of all > comments in a HTML file, HTML comments obviously taking the format > "". > > I'm fairly stumped on how to do this? Maybe using regular expressions? from lxml import etree parser = etree.HTMLParser

Re: Python and UML

2007-10-09 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > On 9 Okt, 12:15, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >>> IMHO UML is ... crap, at least when it comes to actual developing. > > What alternatives are there? What's your use case? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Lamaizm... XML problem...

2007-10-09 Thread Stefan Behnel
durumdara wrote: > from xml.dom import minidom [...] >t_props = t_comp.getElementsByTagName('prop') >for t_prop in t_props: >attrs = t_prop.attributes.keys() >print attrs >print t_prop.nodeName >print t_prop.nod

Re: Unexpected behaviour with HTMLParser...

2007-10-10 Thread Stefan Behnel
Just Another Victim of the Ambient Morality wrote: > HTMLParser is behaving in, what I find to be, strange ways and I would > like to better understand what it is doing and why. In case you also want an HTML library that is easy to use (and powerful and flexible and...), look at lxml.html. h

Re: pyxml package not working? No xml.dom.ext.reader module available after install.

2007-10-10 Thread Stefan Behnel
Thomas W wrote: > I've tried to install the pyxml-package, available at > http://pyxml.sourceforge.net/, > both from source and using some hack on the win32-binary package > available for python2.4, but without luck. After install the module > xml.dom.ext.reader is not available, eventhough the fo

Re: pyxml package not working? No xml.dom.ext.reader module available after install.

2007-10-10 Thread Stefan Behnel
Thomas W wrote: > On 10 Okt, 11:13, Stefan Behnel <[EMAIL PROTECTED]> wrote: >> Thomas W wrote: >>> I've tried to install the pyxml-package, available >>> athttp://pyxml.sourceforge.net/, >>> both from source and using some hack on the win32-binary p

Re: Last iteration?

2007-10-12 Thread Stefan Behnel
Florian Lindner wrote: > can I determine somehow if the iteration on a list of values is the last > iteration? > > Example: > > for i in [1, 2, 3]: >if last_iteration: > print i*i >else: > print i > > that would print > > 1 > 2 > 9 > > > Can this be acomplished somehow? Y

Re: Python's coming... from unexpected angles.

2007-10-16 Thread Stefan Behnel
Ben Finney wrote: > "Eric Brunel" <[EMAIL PROTECTED]> writes: > >> Well, I'd definetely vote for a name change for PyPy, as in french, >> it's pronounced "pee-pee", and yes, it means what you think it >> means... ;-) > > Anyway, the pronunciation of "Python" (and hence the "Py" in "PyPy") > is ho

Re: HTML Parser for Jython

2007-10-17 Thread Stefan Behnel
Falcolas wrote: > Does anybody know of a decent HTML parser for Jython? I have to do > some screen scraping, and would rather use a tested module instead of > rolling my own. Not sure if it works, but have you tried BeautifulSoup? Or maybe an older version of it? Stefan -- http://mail.python.org

Re: ignoring chinese characters parsing xml file

2007-10-22 Thread Stefan Behnel
Fabian López wrote: > Thanks Mark, the code is like this. The attrib name is the problem: > > from lxml import etree > > context = etree.iterparse("file.xml") > for action, elem in context: > if elem.tag == "weblog": > print action, elem.tag , elem.attrib["name"],elem.attrib["url"],

Re: python project ideas

2007-10-25 Thread Stefan Behnel
Evan Klitzke wrote: > but you could also write your own templating engine for this. No, please. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: python project ideas

2007-10-25 Thread Stefan Behnel
Arnaud Delobelle wrote: > On Oct 25, 10:05 am, Stefan Behnel <[EMAIL PROTECTED]> > wrote: >> Evan Klitzke wrote: >>> but you could also write your own templating engine for this. >> No, please. > > I'm afraid it is the inalienable right of every pytho

Re: elementtree w/utf8

2007-10-28 Thread Stefan Behnel
Tim Arnold wrote: > On a related note, I have another question--where/how can I get the > cElementTree.py module? Sorry for something so basic, but I tried installing > cElementTree, but while I could compile with setup.py build, I didn't end up > with a cElementTree.py file anywhere. That's be

Re: problem opening html file with webbrowser.open

2007-10-29 Thread Stefan Behnel
krishnakant Mane wrote: > as I posted in my previous thread, I am generating html reports for my > client software. > I am yet to find a satisfactory module which can help me actually > create headings, bold and italics etc without merging html with data > variables. Maybe this is something for yo

Re: Parsing xml file in python

2007-10-30 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > I am a newbie in python > I am trying to parse a xml file and write its content in a txt file. If you want to write code that does not hide your bugs behind cryptic event handlers and instead helps you get XML work done, try using ElementTree or lxml instead of SAX. The

Re: XML DOM, but in chunks

2007-11-01 Thread Stefan Behnel
Tommy Nordgren wrote: >> On 31 okt 2007, at 21.24, Sean Davis wrote: >> >>> I have some very large XML files that are basically recordsets. I >>> would like to access each record, one-at-a-time, and I particularly >>> like the ElementTree library for accessing the data. Is there a way >>> to have

Re: XML document causes pickle to go into infinite recursion

2007-11-01 Thread Stefan Behnel
Orest Kozyar wrote: > I'm working on a CGI script that pulls XML data from a public database > (Medline) and caches this data using shelveleto minimize load on the > database. In general, the script works quite well, but keeps crashing > every time I try to pickle a particular XML document. Below

Re: XML document causes pickle to go into infinite recursion

2007-11-01 Thread Stefan Behnel
Orest Kozyar wrote: > I'm working on a CGI script that pulls XML data from a public database Ah, I missed that bit on first read. Consider using something different than CGI here if you want to do caching. FCGI would allow you to do in-memory caching, for example, as would mod_python and a lot of

<    3   4   5   6   7   8   9   10   11   12   >