that you can provide a DTD to tell it what whitespace-only
content really is "useless" in the sense of your specific application.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
uot;file descriptor" under Unix is not necessarily an open file that you can
find on the hard-disk. It might also be a socket connection or a pipe, or it
might be a file that was opened or created with specific rights or in an
atomic step (like temporary files).
Many things are (or look lik
ee, which you can also install on Python 2.4 (it's
what later became part of Python 2.5).
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
u can have a fallback to the stdlib if lxml is not
installed (though this will loose comments then).
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
other one
is the standard API of the "list" builtin type, which has an extend() method.
ah-you're-just-jealous-we-had-it-first-ly,
Stefan :)
--
http://mail.python.org/mailman/listinfo/python-list
uot; of automatically removing an Element from the old position
when inserting it at a different place. ElementTree does not do that, so this
code is not portable between the two libraries.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ernatively, try an XML API that makes it easy to handle XML, like
ElementTree (part of the stdlin in Python 2.5) or lxml, both of which have
compatible APIs. The code would look like this:
tree = etree.parse("some_file.xml")
id = tree.find("//LLobjectID")
print id.text
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
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
st compare for equality:
if line == 'x11':
or
print "\n".join(x for x in mylist if x == 'x11')
--
Stefan Bellon
--
http://mail.python.org/mailman/listinfo/python-list
Is there a better way to do the following?
attributes = ['foo', 'bar']
attributeNames = {}
n = 1
for attribute in attributes:
attributeNames["AttributeName.%d" % n] = attribute
n = n + 1
It works, but I am wondering if there is a more pythonic way to
do this.
S.
--
http://mail.python.o
Stefan Arentz <[EMAIL PROTECTED]> writes:
> Is there a better way to do the following?
>
> attributes = ['foo', 'bar']
>
> attributeNames = {}
> n = 1
> for attribute in attributes:
>attributeNames["AttributeName.%d" % n] = attribu
?
from lxml import etree
parser = etree.HTMLParser()
tree = etree.parse("somefile.html", parser)
print tree.xpath("//comment()")
http://codespeak.net/lxml
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
At http://docs.python.org/dist/node12.html it is described how to add
package data to a module. This was pretty easy to do, but now how do I
access this data from my module? Is there an API to load a 'package
resource' ala Java's classloader?
S.
--
http://mail.python.org/mailman/listinfo/python
[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
ldren of t_prop
to find the text node and then read its nodeValue.
Alternatively, consider using an XML library that actually helps users in
working with XML, such as ElementTree or lxml.
http://codespeak.net/lxml
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Is it possible to mix classes defined in both Python and C in the same
module? Ideally I would like to be able to do:
from some.module import MyPythonClass, MyCClass
I guess that would mean that this would look like this on disk:
some/
__init__.py
module.py (contains MyPythonClass)
Is there an easy way to implement a specific method of a Python class
in C? Like a native method in Java? I would really like to do the
majority of my class code in Python and just do one or two methods
in C.
S.
--
http://mail.python.org/mailman/listinfo/python-list
"Chris Mellon" <[EMAIL PROTECTED]> writes:
> On 09 Oct 2007 17:20:09 +0200, Stefan Arentz <[EMAIL PROTECTED]> wrote:
> >
> > Is there an easy way to implement a specific method of a Python class
> > in C? Like a native method in Java? I would really like
l.html.
http://codespeak.net/lxml/dev/lxmlhtml.html
It's part of lxml 2.0, which is currently in alpha status (which does not mean
it's unstable or something, just not as complete as its authors want it to be).
http://codespeak.net/lxml/dev/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
able, eventhough the folder, __init__py
> and everything is in place.
>
> Why? And could someone please make a win32-binary package of pyxml for
> python2.5? Thanks!
PyXML has not been actively maintained for some years now. Use ElementTree or
lxml instead.
http://codespeak.net/lxml
S
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
for item in l[1:]:
print next
next = item
print next * next
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
er here. They do not
pronounce "Monty Python" the way you'd think they do, so the above isn't
actually of any help at all.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
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
the 64-bit library in a sparcv9 directory but shares the other
Python libraries that are ELF-code independent.
Is this possible or do I really have to install two complete but
separate Pythons although most of the files are the same?
--
Stefan Bellon
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 22 Oct, Diez B. Roggisch wrote:
> Stefan Bellon wrote:
> > I can successfully build a 32-bit version in one directory and a
> > 64-bit version in another directory. What I'd like to do is to
> > build a version that has the 64-bit library in a sparcv9 director
m.tag , elem.attrib["name"],elem.attrib["url"],
The problem is the print statement. Looks like your terminal encoding (that
Python needs to encode the unicode string to) can't handle these unicode
characters.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
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
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
setup.py install.
That shouldn't be a problem as long as you keep the binary in your PYTHONPATH.
As suggested before, if you have Python 2.5, you don't even need to install it
yourself.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
for that:
http://docs.python.org/lib/module-webbrowser.html
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
X. The first is in the standard library of Python 2.5, the
second is here:
http://codespeak.net/lxml
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
the record?
>>>
>>> Thanks,
>>> Sean
>>>
>> You need a Python (or other language) implementation of the SAX API
>>
> The module you need is xml.sax
That's unlikely - few people "need" SAX. If they think they do, they just
don't know the alternatives. I think iterparse() is what he was looking for.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
than minidom.
There's also lxml.objectify, in case you can't live without pickeling.
http://effbot.org/zone/celementtree.htm
http://codespeak.net/lxml
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
a lot of other solutions.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
atch the
included "\n".
When using the pattern "X(.|\n)*?Y" (explicity including "\n"
in the set of "any character") I get the wanted result.
My fault or a bug in the module?
Thanks
-stefan-
--
http://mail.python.org/mailman/listinfo/python-list
Just noticed, that it works when *compiling* the pattern:
import re
p = re.compile('X.*?Y', re.DOTALL)
print re.sub(p, 'Z', 'Xab\ncdY')
Still the question - my fault or a bug?
Best regards
-stefan-
On Thu, 18 Jan 2007 11:10:08 +0100, Stefan Palme wrote:
&
arghh.
Thanks for removing my blindness :)
-stefan-
On Thu, 18 Jan 2007 10:38:35 +, Roberto Bonvallet wrote:
> Stefan Palme wrote:
>>> using the "re" module of Python (2.3 and 2.4), I tried the following:
>>>
>>> import re
>>>
revised BSD
license (see http://www.opensource.org/licenses/bsd-license.php ).
Stefan
--
Dr.-Ing. Stefan Schwarzer
SSchwarzer.com - Softwareentwicklung für Technik und Wissenschaft
http://sschwarzer.com
http://ftputil.sschwarzer.net
--
http://mail.python.org/mailman/listinfo/python-list
a
bug-report. Thanks for doing that.
The problem is the code that handles entity and character references in
SGMLParser.parse_starttag. Seems that it is not careful about
unicode/str issues.
My quick'n'dirty workaround was to remove the offending char-entity from
the website before feeding it to Beautifulsoup::
text = text.replace('®', '') # remove rights reserved sign entity
cheers,
stefan
--
http://mail.python.org/mailman/listinfo/python-list
400, 300)
myShape.Select()
xlsapp.Selection.Characters.Text = finalText[0:200]
xlsapp.Selection.GetCharacters(200).Insert(finalText[200:400])
excelfile = "Hello.xls"
wb.SaveAs(excelfile)
wb.Close()
xlsapp.Quit()
Stefan
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EM
on 16.02.2007 13:02 Edward K Ream said the following:
>> There are a tool called "2to3" that translates things like "print foo" to
>> print(foo).
>
> The point of my original post was that if I want to maintain a common code
> base the tool must translate 'print foo' to 'print2(foo)'.
I think y
ofile and
if you ever decide to need more features, there's lxml to the rescue.
You might also consider streaming your XML piece by piece instead of creating
in-memory trees. Python's generators are a good starting point here.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
swers...
Thanks and regards
-stefan-
--
http://mail.python.org/mailman/listinfo/python-list
Boris Ozegovic <[EMAIL PROTECTED]> wrote:
> Umm, can somebody tell me which language is this one:
>No polls are available.
English?
--
http://mail.python.org/mailman/listinfo/python-list
't there a "per-socket timeout"
too?
-stefan-
> I believe this can only be set globally:
>
> import socket
> socket.setdefaulttimeout(seconds)
>
> Peter
--
http://mail.python.org/mailman/listinfo/python-list
>>> [Peter]
>>> I believe this can only be set globally:
>>>
>>> import socket
>>> socket.setdefaulttimeout(seconds)
>>>
>> [Stefan]
>> ...
>> But when there is a "default timeout" (as indicated by
>> the me
were talking about the best of both worlds already) use lxml's HTML
parser, which is also capable of parsing pretty disgusting HTML-like tag soup.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
odespeak.net/lxml/dev/
http://codespeak.net/lxml/dev/lxmlhtml.html
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
r parsing, so there's no need
to fiddle with it on your own - especially since it's pretty hard to get any
faster than the C implementation of ET, cElementTree, is already...
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
old already?
I think it was just a conservative guess that Python 3000 would be out by then.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> what's the equivalent of minidom's getElementsByTagName in ElementTree?
element.findall("//{namespace}tagname")
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
tent. There are
quite a few ways to do that, including lxml.html:
http://codespeak.net/lxml/dev/lxmlhtml.html
>>> htmldata = """This &that
... or the other thing.
>>> from lxml import html
>>> print html.fragment_fromstring(htmldata).text_content()
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
e a built-in
>> solution to what must be a very common problem.
>
> Replace "python" with "c++" and would that seem a reasonable belief?
That's different, as Python comes with batteries included.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
gerclient/atom.py?rev=6717
The usage is mainly the same as in standard ElementTree.
http://codespeak.net/lxml/dev/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
y",
> line 190, in ParseFile
> self._myparser.ParseFile(file)
> xml.parsers.expat.ExpatError: not well-formed (invalid token): line 68,
> column 0
You XML input is broken. This is not a gnosis problem.
Look at line 68 in your XML file.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
hich are in a
>>> subdirectory:
>>>
>>> myPythonApp.py
>>> /resources
>>> image1
>>> image2
>>> etc.
>>>
The following two versions are working for me:
import os, sys
print os.path.abspath(o
Ramdas wrote:
> I am doing some HTML scrapping for a side project.
>
> I need a method using sgmllib or HTMLParser to parse an HTML file and
> get line nos of all the tags
Try lxml.html, it provides line numbers for each element.
http://codespeak.net/lxml/dev/
Stefan
--
http://mai
have more luck
with those, especially since they are XML, so you can work on the schema
documents and extract the sections that are relevant for a specific XML
fragment.
lxml is compatible with the ElementTree API, so you can reuse the ET code you
already have.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
abhishek wrote:
> sh: a2ps: not found
This should make you think. Sounds like a good reason to install a2ps...
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
have this
functionality, and I may use this one later.)
It is possible to convert input in this form (input hook?):
My custom input format:
>>> b := 10a + 0,1
Format send to interpreter after preprocessing:
>>> b = 10*a + 0.1
Best regards
Stefan Salewski
--
http://mail.python.org/mailman/listinfo/python-list
SLT2 or XPath Features with CPython. All
> the usual suspects 4suite or libxslt (via lxml) seem to have no support
> yet. Is there any hope I oversaw something?
I wouldn't know any implementation. Are you looking for a specific feature?
Using Python functions in XPath/XSLT might get yo
Hi,
the feature you expierenced are parameterized properties. This is only
supported
by VB and could only be emulated in python. If you use makepy/gencache
to generate a wrapper
the appropriate Set methods are created:
oR.SetItem(1,2, "4")
Stefan
> -Original Messag
Beware though, I'm somewhat biased as I'm one of the authors.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
support for xml:id through the XMLDTDID function. It simply returns an XML
tree and an ID dictionary.
http://codespeak.net/lxml
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
classes. The
properties
you get with OBJ._prop_map_get_.keys().
Stefan
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of bruno at modulix
> Sent: Friday, April 28, 2006 10:29 AM
> To: python-list@python.org
> Subject: Re:
ll normally not provide a typelibrary but
support dynamic
dispatch.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
;Hello" and "There", despite "Hello"
> and "There" being, in reality, seperate?
Use the "join" method of strings:
print ' '.join(xyz)
--
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
lowed up and screwed with workaround for language limitations (that
are aimed at beginners and less capable programmers).
Why only adjust to the less capable people? Give everyone what they
need and want! :)
--
Stefan.
--
http://mail.python.org/mailman/listinfo/python-list
element.text = text
> return s
>
>
> Why isn't this the standard behaviour ?
Because it wouldn't work. What if you wanted to serialize a different encoding
than that of the strings you put into the .text fields? How is ET supposed to
know what encoding your strings have? And how should it know that you didn't
happily mix various different byte encodings in your strings?
Use unicode, that works *and* is portable.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
you could run out of memory since you have the Python objects
and the
COM data in your process. I think in 207 the patch was included.
Stefan
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Alastair Alexander
> Sent: Mon
his will not copy root-level PIs or internal DTD subsets.
But you can copy PIs and comments by hand.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
already *is* part of stdlib:
the threading module. So the processing module would fit just nicely into the
idea of a "standard" library.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Christian Heimes wrote:
> Stefan Behnel wrote:
> > Well, there is one parallel processing API that already *is* part of
> stdlib:
>> the threading module. So the processing module would fit just nicely into the
>> idea of a "standard" library.
>
> Do
e tree, but it does create a new document, a new
root element, and then moves the root children over from the original
document, which also involves reference adaptations throughout the entire
tree. So it does not come for free. I'd be interested if you can come up with
numbers how it compares
e applies: I can't see the problem you are talking about.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Peter Pei wrote:
> To be preise
[...]
Preise the lord, not me. :)
Happy New Year!
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
't currently a way to automatically bootstrap an
implementation, especially not in XSD, so it depends on the language how much
work it will be to get this to a usable state.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ng is inherently an XML
> *fragment*.
Not inherently, no. I know some people who do web processing with an XML
document coming in as a string (from an HTTP request) and a result XML
document going out as a string. I don't think that's an uncommon use case.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh wrote:
> Stefan Behnel wrote:
>
>>> My take on the API decision in question was always that a file is
>>> inherently an XML *document*, while a string is inherently an XML
>>> *fragment*.
>>
>> Not inherently, no. I know some people
No, py2exe does not display such information but has an algorithm to
collect such information.
Perhaps this is a starting point for you.
Stefan
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Bernhard Merkle
Sent: Friday, January 04, 2008 2:25 PM
To
Hi,
try to look at py2exe. This module scans all dependencies to pack them
into one executable.
Stefan
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Bernhard Merkle
Sent: Friday, January 04, 2008 1:14 PM
To: python-list@python.org
Subject
so few, you could already have added the patch
anyway. :)
However, I'd just submit it to Python's bug tracker. Broken documentation is
something that should be fixed.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Henry Chang wrote:
> On Jan 7, 2008 5:41 AM, alain <[EMAIL PROTECTED]> wrote:
>> Paraphrasing Steve Jobs but in this context:
>> PYTHON = a bycycle for the mind
> What exactly does it mean "a bycycle for the mind"??
Ask the Dutch guy near you.
Stefan
--
http:
lxml supports the same thing, BTW, and how to work with namespaces is
explained in the tutorial:
http://codespeak.net/lxml/dev/tutorial.html#namespaces
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
>> >>> re.sub("[ \n\r\t]+", " ", u"foo\n frab\xa0farn")
>> u'foo frab\xa0farn'
>>
>>
>
> Yes, partially. Leading and trailing whitespace has to be removed
> entirely, not replaced by one space.
Sounds like adding a .strip() to me ...
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
#x27;
return bool(func.func_code.co_flags & CO_GENERATOR)
cheers,
stefan
--
http://mail.python.org/mailman/listinfo/python-list
on 22.01.2008 16:09 Paul McGuire said the following:
> On Jan 22, 7:46 am, Stefan Rank <[EMAIL PROTECTED]> wrote:
>> I also need to test for generator functions from time to time for which
>> I use::
>>
>>def _isaGeneratorFunction(func):
>>'
than what you already
invested to learn 'the wrong thing'. It's what people on this list tend to
call their "unlearning curve".
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
parser.setElementClassLookup(lookup)
tree = etree.parse(filename, parser)
for row in tree.iterfind("//Row"):
print row.relationship, row.StartDate, row.Priority * 2.7
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
u to use lxml,
which uses the parser and DTD validator of libxml2.
http://codespeak.net/lxml/dev/
http://codespeak.net/lxml/dev/validation.html
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
quot;other XML technologies", it's only about making the standard
XML technologies accessible and usable. It's about designing interfaces in a
way that matches the tool people are using anyway, which in this case is Python.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
lained what your actual intention is?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> What to one do if one what to use lxml(http://codespeak.net/lxml/
> index.html) on a mac?
Have you tried installing up-to-date versions of libxml2/libxslt and running
easy_install lxml
?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> On Jan 23, 4:19 pm, Stefan Behnel wrote:
>> [EMAIL PROTECTED] wrote:
>>> What to one do if one what to use lxml(http://codespeak.net/lxml/
>>> index.html) on a mac?
>> Have you tried installing up-to-date versions of libxml2/libxslt and r
//Row"):
> AttributeError: 'etree._ElementTree' object has no attribute
> 'iterfind'
>
>
> Is there some kind of newer version of lxml?
Yep, lxml 2.0. It's currently in beta, but that doesn't say much.
http://codespeak.net/lxml/dev/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
rst, without sorting the file? (or sort
it afterwards if you still need to). That would heavily cut down your memory
footprint.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Stefan Behnel wrote:
> [EMAIL PROTECTED] wrote:
>>> What are you going to do with it after it's sorted?
>> I need to isolate all lines that start with two characters (zz to be
>> particular)
>
> "Isolate" as in "extract"? Remove the rest?
&
Ever heard the word "PLONK"?
Peter Pei harshly top-posted:
> You didn't understand my question, but thanks any way.
>
> Yes, it is true that %s already support unicode, and I did not
> contradict that. But it counts the number of bytes instead of
> characters, and makes things like %-20s out of a
e sort command has no limit on file size.
Sure, since no-one can ever try it with more than 640k, it's easy to state
that there is no limit. :)
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
1001 - 1100 of 2239 matches
Mail list logo