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

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

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 Scholl
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 correct > encoding. There's no reason you should have an XML document (as > opposed to values extracted from that document) in unic

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

2007-07-26 Thread Stefan Scholl
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 >>>> the fact, that I can't use Un

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 Scholl
Stefan Behnel <[EMAIL PROTECTED]> wrote: > 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, ple

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

2007-07-27 Thread Stefan Scholl
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 wo

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

Re: Removing certain tags from html files

2007-07-27 Thread Stefan Behnel
er BeautifulSoup for parsing (just in case you're not dealing with HTML-like pages, but just with real tag soup), you can also use the ElementSoup parser: http://codespeak.net/svn/lxml/branch/html/src/lxml/html/ElementSoup.py but lxml is generally quite good in dealing with broken HTML already. Have fun, Stefan -- http://mail.python.org/mailman/listinfo/python-list

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

2007-07-28 Thread Stefan Scholl
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 gen

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 >&g

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

2007-07-28 Thread Stefan Scholl
Stefan Behnel <[EMAIL PROTECTED]> wrote: > Stefan Scholl wrote: >> But the style of the answers makes me wonder if I should report >> the bug in xml.sax (or its documentation) or just ignore it. > > Note that PyXML is no longer actively maintained, so it's unlike

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

2007-07-28 Thread Stefan Scholl
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 >> > >

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). >>>

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

2007-07-28 Thread Stefan Scholl
Michael L Torrie <[EMAIL PROTECTED]> wrote: > Stefan Scholl wrote: >> Don't let the subject line fool you. I'm OK with cStringIO. The >> thread is now about xml.sax's parseString(). > > Giving you the benefit of the doubt here, despite the fact that St

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

Re: Iteration over strings

2007-08-01 Thread Stefan Behnel
able 'str' directly. I'm still pretty new >> to Python so if someone could explain to me why this isn't working and what >> I can do to achieve the same effect I would greatly appreciate it. I assume what you are actually looking for is the os.path module.

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

2007-08-01 Thread Stefan Behnel
Try one of these (I looked for "minidom example"): http://www.faqs.org/docs/diveintopython/kgp_parse.html http://docs.python.org/lib/dom-example.html http://www.cutthecrap.biz/software/whitepapers/minidom.html Maybe that helps? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: force unicode strings

2007-08-01 Thread Stefan Behnel
he string it is hard to find it. I guess you can't afford to wait for Python 3, can you? http://www.python.org/dev/peps/pep-3100/#atomic-types Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Emacs + python

2007-08-01 Thread Stefan Behnel
Apart from that, see here: http://www.python.org/emacs/ Stefan -- http://mail.python.org/mailman/listinfo/python-list

Catching SystemExit in C API code when embedding Python?

2007-08-02 Thread Stefan Bellon
is not the intended behaviour. As in Python itself you can catch SystemExit, I think this should be the way to go. But how do I catch this exception from within the C API? Thanks in advance for any hints. -- Stefan Bellon -- http://mail.python.org/mailman/listinfo/python-list

Re: Catching SystemExit in C API code when embedding Python?

2007-08-02 Thread Stefan Bellon
First of all, I'm sorry to followup my own posting, but I can add a few things ... On Thu, 02 Aug, Stefan Bellon wrote: > As in Python itself you can catch SystemExit, I think this should be > the way to go. But how do I catch this exception from within the C > API? I now installe

Re: Catching SystemExit in C API code when embedding Python?

2007-08-02 Thread Stefan Bellon
dled but raised "out of" the interpreter. So I am unsure of what you mean with "Call python code". When installing an excepthook (see my other posting), then I can indeed catch all exceptions ... except for SystemExit which is the one I'm after. -- Stefan Bellon -- http://mail.python.org/mailman/listinfo/python-list

Re: Catching SystemExit in C API code when embedding Python?

2007-08-02 Thread Stefan Bellon
On Thu, 02 Aug, Farshid Lashkari wrote: > You cannot use PyRun_SimpleString, since it will automatically print > and clear the error. You will need to use PyRun_String instead. Thanks, that helps a lot! -- Stefan Bellon -- http://mail.python.org/mailman/listinfo/python-list

Re: How to read information from tables in HTML?

2007-08-03 Thread Stefan Behnel
//codespeak.net/svn/lxml/branch/html/ A release is expected soon. Stefan -- http://mail.python.org/mailman/listinfo/python-list

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

2007-08-03 Thread Stefan Behnel
enting it) might not be that easy... Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: replacement for execfile

2007-08-03 Thread Stefan Bellon
PyRun_String functions and execute a string with the content "execfile('filename')". Is there a way to solve this problem with PyRun_File? -- Stefan Bellon -- http://mail.python.org/mailman/listinfo/python-list

Destruction of generator objects

2007-08-07 Thread Stefan Bellon
Is there a way around this? Can I add some sort of __del__() to the generator object so that in case of an early destruction of the generator object, the external resource is freed as well? I'm looking forward to hearing your hints! -- Stefan Bellon -- http://mail.python.org/mailman/listinfo/python-list

Re: Destruction of generator objects

2007-08-08 Thread Stefan Bellon
On Wed, 08 Aug, MRAB wrote: > Simple! :-) Sorry, I forgot to mention that I am forced to using Python 2.4. -- Stefan Bellon -- http://mail.python.org/mailman/listinfo/python-list

Re: Destruction of generator objects

2007-08-08 Thread Stefan Bellon
lse in a way that works even with Python 2.4 and can then be nicely written without cluttering up the logic between consumer and producer? -- Stefan Bellon -- http://mail.python.org/mailman/listinfo/python-list

Re: Destruction of generator objects

2007-08-11 Thread Stefan Bellon
On Sat, 11 Aug, Kay Schluehr wrote: > On Aug 9, 1:14 am, Stefan Bellon <[EMAIL PROTECTED]> wrote: > > Sorry, I forgot to mention that I am forced to using Python 2.4. > It doesn't matter. You can use try...finally as well in Python 2.4. > It's just not possible to

Re: Destruction of generator objects

2007-08-11 Thread Stefan Bellon
em1', 'Item2', 'Item3', 'Item4'] But I do not see an output of "gen del" which makes me think that the destructor is not called, thus not releasing the resource. It seems I have not completely understood how generators work ... -- Stefan Bellon -- http://mail.python.org/mailman/listinfo/python-list

Re: Destruction of generator objects

2007-08-11 Thread Stefan Bellon
led. When taking out the yield statement, __del__ is called again. It looks to me that as soon as a generator function is involved in the class, the __del__ is not called anymore. -- Stefan Bellon -- http://mail.python.org/mailman/listinfo/python-list

Re: Destruction of generator objects

2007-08-11 Thread Stefan Bellon
On Sat, 11 Aug, Marc 'BlackJack' Rintsch wrote: > On Sat, 11 Aug 2007 14:50:33 +0200, Stefan Bellon wrote: > > But then, even when terminating the interpreter, __del__ is not > > called. > > Because that is not guaranteed by the language reference. The reason &

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
is >>> text = element.text or "" BTW, you'd be even more surprised to see that ET can actually /store/ "" as text if you tell it to, and then returns an empty string when you ask for the .text property. But any empty text coming from the parser will alway

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

2007-08-17 Thread Stefan Behnel
rocess more or less like a thread, thus avoiding GIL issues completely. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorting a list of Unicode strings?

2007-08-19 Thread Stefan Behnel
x27;s because "Unicode" is more than one alphabet. unicode objects compare based on the Unicode character value, so sort() does alike. Stefan -- http://mail.python.org/mailman/listinfo/python-list

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

2007-08-20 Thread Stefan Behnel
speak.net/lxml/dev and you can (easily) install it from Subversion sources: http://codespeak.net/svn/lxml/trunk Have fun, Stefan -- http://mail.python.org/mailman/listinfo/python-list

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

2007-08-21 Thread Stefan Behnel
t's only a matter of > taste. lxml.html handles bad HTML and it's a powerful tool that is very easy to use. And if one day you have to deal with really, *really* broken tag soup, it also comes with BeautifulSoup parser integration. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: SCF released GPL

2007-08-27 Thread Stefan Behnel
d it IS subversion). It's Google, though, so it requires people to register with Google to work on the project. Might be a blocker for some contributors. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: SCF released GPL

2007-08-27 Thread Stefan Behnel
support by now. You can choose between CVS or SVN. Berlios works alike, and it's Europe based. http://developer.berlios.de/ > I'm not sure what Launchpad uses. Launchpad is Ubuntu, meaning it uses Bazaar. It has SVN integration, though. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting a list of lists

2007-08-27 Thread Stefan Behnel
parator) > > def mycomparator(a, b): > #do Taking advantage of stable sorting is totally not a hack. The OP just tried the two sorting steps in the wrong order. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Haskell like (c:cs) syntax

2007-08-28 Thread Stefan Niemann
lement of a list and 'tail' matches the rest? I could not find this in the Python documentation. Regards, Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: replacing xml elements with other elements using lxml

2007-08-29 Thread Stefan Behnel
with picked content here > > now that I have the contents tag randomly chosen, how do I delete the > parent tag, and replace it to look like this: > > final xml sample (goal): > Here is some content. > Here is some random content. > Here is some content. what about: r.getparent().replace(r, random.choice(r)) ? Stefan -- http://mail.python.org/mailman/listinfo/python-list

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 Emac

Re: Haskell like (c:cs) syntax

2007-08-29 Thread Stefan Niemann
when iterables are involved. Stefan "Matimus" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] >> Is there a pattern matching construct in Python like (head : tail), >> meaning >> 'head' matches the first element of a list and 'tail

Re: replacing xml elements with other elements using lxml

2007-08-30 Thread Stefan Behnel
: parent[2:3] = child[1:5] should work. > lxml rocks! I know, but it feels good to read it once in a while. :) Stefan -- http://mail.python.org/mailman/listinfo/python-list

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

2007-08-30 Thread Stefan Behnel
is (the invalid character is the > final é of Université): > > /C=BE/O=BEGRID/OU=Physique/OU=Univesité Catholique de > Louvain/CN=Roberfroid > > > I have tried several options but I am not able to avoid this > problem. Any idea?. Looks like the page is not well-formed XML (i.e. not XML at all). If it doesn't specify an encoding (), you can try recoding the input, possibly decoding it from latin-1 and re-encoding it as UTF-8 before passing it to the SAX parser. Alternatively, tell the page authors to fix their page. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple elementtree question

2007-08-30 Thread Stefan Behnel
m/rss/rss.xml";) > nTree = ET.parse(news) > for item in nTree.getiterator("title"): > print item.text > > Whether I try this for title or link, nothing is printed. Your document uses namespaces. What you are looking for is not the tag "title" without a nam

Re: Simple elementtree question

2007-08-31 Thread Stefan Behnel
.XPath("//channel[title = $title]") >>> tree = objectify.parse("http://somewhere/the_document.xml";) >>> channel = find_channel(tree, title="example title") >>> print channel.title, channel.link http://codespeak.net/lxml Stefan -- http://mail.python.org/mailman/listinfo/python-list

RE: win32com problem: more than one instance

2007-08-31 Thread Stefan Schukat
instances running in any COM client. Stefan > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Tim Golden > Sent: Friday, August 31, 2007 1:36 PM > To: Thomas Rademacher > Cc: python-list@python.org > Subject: Re: win

Re: Python object <-> XML

2007-09-03 Thread Stefan Behnel
codespeak.net/lxml/objectify.html#element-access-through-object-attributes http://codespeak.net/lxml/objectify.html#python-data-types http://codespeak.net/lxml/objectify.html#defining-additional-data-classes It's part of lxml, which makes it plenty fast, highly flexible and gives you

Re: We need PIGs :)

2007-09-06 Thread Stefan Arentz
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: ... > The problem with Java is that it makes it very painfull to bridge two > APIs together, while Python usually makes it a breeze (easy > delegation, no dumb-ass psycho-rigid type system). So Java's solution > (hyper-formalization) isn't necessary

Re: We need PIGs :)

2007-09-06 Thread Stefan Arentz
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > On Thu, 06 Sep 2007 09:00:02 +0200, Stefan Arentz wrote: > > > What I find really frustrating in Python (combined with usually bad > > documentation) is that many people have different styles. The most >

Re: How to do python and RESTful

2007-09-06 Thread Stefan Arentz
Michele Simionato <[EMAIL PROTECTED]> writes: > On Sep 5, 9:54 pm, MarkyMarc <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > I want to make a web service application in python and keywords are > > RESTful, python and nice urls(urls mapped to python objects). > > > > I don't want a big framework but

Re: Nudge needed for rst to html

2007-09-06 Thread Stefan Rank
t;, writer_name="html") > > > > would do the trick, but that produces an entire document with > an embedded style block. try this:: import docutils.core parts = docutils.core.publish_parts("Hello!", writer_name="html") html = parts[

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-07 Thread Stefan Arentz
[EMAIL PROTECTED] writes: > Hi there > > I am fairly new to Python and have not really used regular expressions > before (I think this might be needed for my query) and wondered if you > could help > > I have a step class and store in a list step instances > A step instance contains variables: n

Re: Python syntax wart

2007-09-08 Thread Stefan Behnel
) >> #end for > > What do you mean by not possible!? This compiles fine for me. He means he has to use backslashes instead of parentheses here. Which is not true, you could easily rephrase this as: for link in GetEachRecord( "links", ): out.write( ) See? No backslash! Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-09 Thread Stefan Arentz
Miki <[EMAIL PROTECTED]> writes: > > steps.sort(key = lambda s: s.time) > This is why attrgetter in the operator module was invented. > from operator import attrgetter > ... > steps.sort(key=attrgettr("time")) Personally I prefer the anonymous function over attrgettr :) S. -- http://mail.pyt

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
hich is precisely the point. This actually sounds somewhat pointless to me. If complex things don't fit into one line, a good way to deal with it is not to insist on making them a single statement. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-10 Thread Stefan Arentz
[EMAIL PROTECTED] (Alex Martelli) writes: > Stefan Arentz <[EMAIL PROTECTED]> wrote: > > > Miki <[EMAIL PROTECTED]> writes: > > > > > > steps.sort(key = lambda s: s.time) > > > This is why attrgetter in the operator module

Re: XML: SAX and XInclude

2007-09-10 Thread Stefan Behnel
de-and-elementinclude http://codespeak.net/lxml/parsing.html#iterparse-and-iterwalk It's not half as complicated as SAX, BTW. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3K or Python 2.9?

2007-09-12 Thread Stefan Behnel
ise in a language. > > If this was needless, why do C++ and Java have the "this" pointer? Be careful when you use the word "needless" in the context of Java. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating HTML

2007-09-12 Thread Stefan Behnel
raight forward support for generating HTML and comes with a lot of nice goodies for HTML handling: http://codespeak.net/lxml/dev/lxmlhtml.html#creating-html-with-the-e-factory Note that this requires lxml 2.0, which is currently in alpha status. Stefan -- http://mail.python.org/mailman/listinfo/python-list

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

2007-09-13 Thread Stefan Behnel
st hand in the result of urlopen(). Apart from that, I saw that you found your way to the lxml mailing list, I'll respond over there. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3K or Python 2.9?

2007-09-13 Thread Stefan Bellon
first parameter (like in Ada 95) or you can call the method on the object (like in Java, C++, Python, ...) and the object is passed implicitly. -- Stefan Bellon -- http://mail.python.org/mailman/listinfo/python-list

Re: pop method question

2007-03-03 Thread Stefan Scholl
Nicholas Parsons <[EMAIL PROTECTED]> wrote: > I realize that in this context it is used for removing a specific key > from the current dictionary object. But why call it pop and not > something more intuitive like remove or delete? I wasn't a python programmer back than, but I'd guess it's be

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

2007-03-05 Thread Stefan Behnel
no-one mentioned lxml so far: http://codespeak.net/lxml http://codespeak.net/lxml/dev/parsing.html#parsers Parse it as HTML and then use anything from XPath to XSLT to treat it. Have fun, Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python object to xml biding

2007-03-05 Thread Stefan Behnel
he xml -> python and python->xml > marshalling/unmarshalling much like jaxb for java. Consider using lxml.objectify. It's extremely powerful and simple to use at the same time. http://codespeak.net/lxml/dev/objectify.html#element-access-through-object-attributes http://codespeak.net/lxml

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

PyX in Console and Script IDE

2007-04-12 Thread Stefan Schwärzler
Hi NG, i'm hanging with following problem in python: i have installed PyX to generate eps in python. in console-mode (call python in shell) there are no problem. calling pyx via python-script i got the following error (in a python ide f.e. wing2.0): ImportError: No module named _pykpathsea Have i

Re: Python and XML?

2007-04-14 Thread Stefan Behnel
already be what you were looking for anyway. http://codespeak.net/lxml Have fun, Stefan -- http://mail.python.org/mailman/listinfo/python-list

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

2007-04-14 Thread Stefan Behnel
t; city="LA"/> >pl_h="No Data" name="MyHouse" address="there" phone="555-5556" > country="US" city="New York"/> > This should help you to get namespaces working: http://effbot.org/zone/element.htm#xml-namespaces Hope it helps, Stefan -- http://mail.python.org/mailman/listinfo/python-list

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

2007-04-14 Thread Stefan Behnel
> for row in csvreader: > mainbox = SubElement(root, "{Boxes}box") > r2 = csv.reader(myfile) > b = r2.next() > mainbox.put("city", b[10]) [...] ElementTree(root).write('test.xml', "UTF-8", xml_declaration=True, pretty_print=True) Hope it helps, Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and XML?

2007-04-15 Thread Stefan Behnel
That's why I was asking why you need this. Validation is provided by RNG itself, so all you would need is some kind of mapping that outputs and parses it for you? What's your target format? Python objects? http://codespeak.net/lxml/objectify.html Stefan -- http://mail.python.org/mailman/listinfo/python-list

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 stan

Re: What makes an iterator an iterator?

2007-04-18 Thread Stefan Rank
have beautiful plumage!".split(): yield word def __iter__(self): self.generator = self._next() return self def next(self): return self.generator.next() cheers, stefan -- http://mail.python.org/mailman/listinfo/python-list

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.

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
; for i in s: > ... if i!="\\": > ... newS=newS+i I'm not quite sure what you're trying to achieve, but I'd use >>> r"\\a\\b\c".replace("", "") 'ab\\c' >>> r"\\a\\b\c".replace("\\", "") 'abc' Note that "\\" in the source is unescaped to "\" in the string. Use r"\\" to prevent that. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: SVG to raster conversion.

2007-09-16 Thread Stefan Behnel
dpi) > raster_image.write(out_file) > > Thanks for any pointers you might have. The GIMP can do it, and you can even program it in Python. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Extracting xml from html

2007-09-18 Thread Stefan Behnel
esn't add any namespaces, so you will not magically get valid XHTML or something. You could rewrite the tags by hand, though. Stefan -- http://mail.python.org/mailman/listinfo/python-list

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
tart from that: row = tree.find("//Row") print row.findtext("primaryowner") print row.findtext("customeraddress") See the lxml tutorial on this, as well as the documentation on XPath support and tree iteration: http://codespeak.net/lxml/xpathxslt.html#xpath http://codespeak.net/lxml/api.html#iteration Hope this helps, Stefan -- http://mail.python.org/mailman/listinfo/python-list

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 -- htt

Re: Extracting xml from html

2007-09-19 Thread Stefan Behnel
Error: 'NoneType' object has no attribute 'findtext' Well, error handling is up to you. If find() doesn't find what you are looking for, it will return None. Note that tag names are case sensitive - or maybe there are namespaces involved, cannot tell from the example you posted. Stefan -- http://mail.python.org/mailman/listinfo/python-list

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
ant (and feature rich anyway). Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: newb: BeautifulSoup

2007-09-20 Thread Stefan Behnel
tware that can process XML and HTML the same way *and* that supports XPath and tree iteration so that you can easily select the content you want. http://codespeak.net/lxml/ Stefan -- http://mail.python.org/mailman/listinfo/python-list

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

2007-09-21 Thread Stefan Behnel
gt; >> Oh, and >> <http://ars.userfriendly.org/cartoons/?id=20070910&mode=classic>. > > Esc-Meta-Alt-Ctrl-Shift? :) Yep, that's five of them. Stefan -- http://mail.python.org/mailman/listinfo/python-list

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

2007-09-21 Thread Stefan Behnel
you use it as a news >>> client :/) Stefan -- http://mail.python.org/mailman/listinfo/python-list

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

2007-09-21 Thread Stefan Behnel
;>>> print 'toto' in a > True Not sure what you're trying to achieve, but the semantics of the "in" operator make it return a boolean value. The string "yop" evaluates to the boolean value True, as it is not empty. Stefan -- http://mail.python.org/mailman/listinfo/python-list

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
re responding, removing quoted text irrelevant to your response.) >>>> >> >> Wayne, may I second Ben on his suggestion to stop top-posting ? > > Well, you may. Unfortunately, there are many NGs that do the opposite. Well, not this one. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: elementtree question

2007-09-24 Thread Stefan Behnel
ldren = list(body) div = etree.SubElement(body, "div", {"class" : "remapped"}) div.extend(children) http://codespeak.net/lxml/ and for lxml.html, which is currently in alpha status: http://codespeak.net/lxml/dev/ ET 1.3 will also support the extend() function, BTW. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: rules from an xml file

2007-09-24 Thread Stefan Behnel
/element_classes.html http://codespeak.net/lxml/dev/element_classes.html#id1 Especially these two class lookup schemes might be handy: http://codespeak.net/lxml/dev/element_classes.html#custom-element-class-lookup http://codespeak.net/lxml/dev/element_classes.html#namespace-class-lookup And here is an example: http://codespeak.net/svn/lxml/trunk/src/lxml/html/__init__.py Have fun, Stefan -- http://mail.python.org/mailman/listinfo/python-list

<    5   6   7   8   9   10   11   12   13   14   >