Hai Vu, 28.02.2010 17:41:
> By the way, Stefan, I am using Python 2.6. Do you know the differences
> between ElementTree and cElementTree?
Use cElementTree, it's implemented in C and a lot faster and more memory
friendly.
http://effbot.org/zone/celementtree.htm#benchmarks
http://co
Hal Styli, 01.03.2010 00:15:
> Stefan, I was happy to see such concise code.
> Your python worked with only very minor modifications.
>
> Hai's test xml data *without* the first and last line is close enough
> to the data I am using:
>
>
>
>
>
>
&g
I can detect new removable drives?
You could execute a script from HAL, e.g. using halevt, and let the script
communicate with your program.
http://www.nongnu.org/halevt/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
speed up your C wrapper code.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
News123, 03.03.2010 10:37:
Stefan Behnel wrote:
Take a look at Cython instead, it will allow you to access PIL's image
buffer directly, instead of copying the data. It will also simplify and
speed up your C wrapper code.
I don't know Cython. Having looked at the web site I'm no
27;m wondering - is there any work being done identifying ..
(1) what is so good with CPAN?
(2) how can it be brought to the Python world?
Is there a working group/initiative for this? Web page? Discussion group?
I think the right place to discuss any deficiencies of PyPI compared to
CPA
Stefan Behnel, 03.03.2010 13:52:
Olof Bjarnason, 03.03.2010 13:45:
The "Where is CPAN for Python?" question keeps popping up, with
answers ranging from "There is no CPAN for Python" and "We already
have CPAN for Python" (confusing).
It confuses me that you
to:
http://effbot.org/zone/element-soap.htm
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
et/mailman/listinfo/lxml-dev
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Jussi Piitulainen, 04.03.2010 22:40:
Stefan Behnel writes:
Jussi Piitulainen, 04.03.2010 11:46:
I am observing weird semi-erratic behaviour that involves Python 3
and lxml, is extremely sensitive to changes in the input data, and
only occurs when I name a partial result. I would like some help
mohamed issolah, 06.03.2010 14:07:
I want to create a compiler which transform a code like pascal code (that
what I do in C) to "quad"
In C, I use BISON and FLEX tools.
Hi,
please stop starting new threads for the same topic. Instead, reply to
responses you get.
Stefa
ot;ranges" seems to fall into the same bucket, but I guess that's just
because I can't extract the meaning from your code snippet (which is not a
good sign).
Try to use expressive names in your code, so that people who look at it for
the first time get an idea about what it does with what kind of data.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
thing
comparable, but I doubt it.
Just out of curiosity, is this syntax converter actually used for any real
projects?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
virtual machine.
http://fperez.org/py4science/ucb/talks/20091118_copperhead_bcatanzaro.pdf
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
only have an
element.
see http://effbot.org/zone/element.htm#accessing-parents
Also note that there is an independent ElementTree implementation called
lxml.etree, which has parent pointers.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
nk the easiest is to iterate not over the elements themselves, but
over their parents, and then to remove all children of the specified tag in
each step.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
in Python ?
Here's a still incomplete but not so short list of web frameworks in Python:
http://wiki.python.org/moin/WebFrameworks
You might be interested in the templating frameworks if all you want is
generate static pages.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Chris Withers, 10.03.2010 17:46:
kj wrote:
Subject line pretty much says it all: is there a book like "Effective
Java"
oxymoronic, no?
Sorry, couldn't resist ;-)
Nothing to excuse for. I thought exactly the same thing.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
vestate.com/recipes/langs/python/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
language but rather restricts
Python syntax to C language features (plus a bit of header file
introspection, it seems, but C's preprocessor has a bit of that, too).
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ed a for loop in
your C code.
Finally, I'm not sure why you think that these 30% matter at all. In your
original post, you even state that seek-time isn't the "deal breaker", so
maybe you should concentrate on the real issues?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
?
Could anyone suggest other methods of these kind of string matching in
Python?
If what you are trying to match is in fact a set of strings instead of a
set of regular expressions, you might find this useful:
http://pypi.python.org/pypi/acora
Stefan
--
http://mail.python.org/mailman/listinfo
sing the regexp. That's
doable in a couple of lines.
But unless you provide more information, it's hard to give better advice.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
eback (most recent call last):
File "", line 1, in ?
ImportError: No module named antigravity
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
moerchendiser2k3, 16.03.2010 17:08:
But the stack is empty after PyObject_Call, isnt it?
I think Steve was expecting that you wanted to debug into your program,
step into the call, and find the line yourself.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
the return
value of PyObject_Call is?
Could you explain what you want to do with this information and in what
cases you need it? Do you want to extract the information programmatically
at runtime?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
also for non-Python functions.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
27;ll just know it!
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
)
It would be nice if you could start reading the posts before you answer,
and then try to give an answer that fits the question.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
execute it. The
subprocess module is the tool of choice here. To use a DLL, link against it.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Dave Angel, 17.03.2010 12:14:
Stefan Behnel wrote:
I think the point here is that executable binaries are not supposed to
be used as libraries. Libraries are. That's the difference between a
DLL and an executable in the first place. To run an executable,
execute it. The subprocess module i
for and how they are supposed to be
used by your own code and by external code. That will allow us to give an
advice on how to design your module better.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
moerchendiser2k3, 17.03.2010 23:35:
1) put the line number information into the message string when you raise
the exception
you mean the line and file information of the C code, right?
Funny that you (being the OP) ask *me* what kind of line information *you*
want.
Stefan
--
http
an apology.
Otherwise, it becomes grounds for an abuse complaint to your ISP.
I hope you just had a bad day. Threatening others for figuring out your
e-mail address is even worse than posting with an illegal e-mail address.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
were not aware that you're posting your mail
address in plaintext in every article?
Uhm - where?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
moerchendiser2k3, 18.03.2010 14:58:
Funny that you (being the OP) ask *me* what kind of line information *you*
want.
Stefan
Well, I need the line/file information of Python :
Then please explain what kind of Python line number you expect to find in C
code.
Hint: providing details often
guess.
Could you explain why you want to know the line number?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
r, after all.
Again, take a look at Cython, where you can do the introspection in Python
code.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
line the word 'might'
in the second. As this newsgroup shows, very often it's enough to look for
a better algorithmic approach first.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
is
possibility, common string hash functions make it so rare in practice that
a hash table will almost always outperform a trie for exact lookups. If it
happens, it will either show up clearly enough in benchmarks or not be
worth bothering.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
hon2 program and don't want to rewrite everything that uses that
script.
Are you writing text or binary data to stdout?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
switches to the new 'io' module and works around this issue in older Python
versions is available:
http://hg.cython.org/cython-devel/raw-rev/751bdd38b55c
That being said, the simplest way to work around this issue is to switch to
Unix line endings in your source file. Most ed
about exception handling but rather about
reporting incorrect return values.
This is a good example when you need a reason why not to split threads on
the same subject...
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
(which defaults to 0).
What part of that suggested to you that sum might not be polymorphic?
Sure, it says numbers (which should be changed, in my opinion), but it
doesn't specify what sort of numbers -- ints, floats, or custom types
that have an __add__ method.
WTF.
Warning: trut
ask you to come back with an implementation that has proven to be useful in
practice.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
d first.
See the PyInterpreterState and PyThreadState functions here:
http://docs.python.org/c-api/init.html
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
h a helper
package to do this "clean" processing.
Take a look at lxml.html.clean first.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
e conversion to a unicode string.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
scrapy about the expected page
encoding, so that it can return correctly decoded unicode strings directly,
instead of resorting to dirty hacks that may or may not work depending on
the page you are parsing.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
)) +
(math.log(1)/math.log(2) - math.log(2)/math.log(2)))*math.log(2))
0.25
The above can be rewritten as
print('0.25')
which is much faster and also a lot more readable.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
; being a list, even if static analysis
can't prove that.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
, a deque is a better option.
In any case, if you tell us more about what you actually want to do, we can
give better suggestions.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
.o
> -L/usr/local/lib *-lpython2.6* -o build/lib.aix-5.3-2.6/cStringIO.so
Try these flags: -L. -L/usr/local/lib
If this solves the problem and the issue is also present in Python-2.7,
you should report a bug at http://bugs.python.org/ .
Stefan Krah
--
http://mail.python.org/mailman/listinfo/python-list
Rustom Mody, 28.11.2010 11:58:
Does anyone know of something like this for python?
http://www.vimeo.com/13240481
The page seems to require a recent version of the Flash player. Could you
describe what exactly you are looking for?
Stefan
--
http://mail.python.org/mailman/listinfo/python
nary? (and,
if the latter, from where?)
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
27;)
# should print [,]
Yep, either use lxml.etree's HTML parser or lxml.html.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
u should open
the file with a well defined encoding (using codecs.open() or io.open() in
Python >= 2.6), and then write the unicode strings into it just as you get
them.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Alex van der Spek, 07.12.2010 12:11:
Does anyone know how to call functions from FORTRAN dlls in Python? Is
it even possible?
Sure, have a look at fwrap and Cython.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Python 3.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
sier to keep it
portable across CPython versions (and C compilers). It's also a lot easier
to write it in the first place.
Note also that Py3.2 introduces a stable ABI for extension modules. This
implies a stable API as well.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
different variable within the block.
Yep, keeps you from writing bad style code like the above.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
John Nagle, 11.12.2010 00:51:
On 12/10/2010 3:25 PM, Stefan Behnel wrote:
Benjamin Kaplan, 11.12.2010 00:13:
On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita wrote:
The only scopes Python has are module and function.
There's more. Both a lambda, and in Python 3.x,
list comprehen
.x versions), as the
runtimes are not binary compatible.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
g.
Even if you have already written a major part of your code in C, it's worth
considering to (re-)write the Python API wrapper parts in Cython if you
need better performance.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
moving forward.
If 3x is not enough for you, I strongly suggest you try Cython. The C code
that it generates compiles nicely in all major Python versions, currently
from 2.3 to 3.2.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
=search&term=openoffice
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
guaranteed to work, either.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
still own the reference when it returns and have
to manually decref it (again, a thing that you won't usually have to care
about in Cython). So, yes, the above leaks one reference for each call to
Py_BuildValue().
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
type from C code.
Maybe I'm over-thinking this whole thing. Is there a simple way that I
can define a class in Python and instantiate that type from C?
Sure, see my previous comments to your original mail.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ory, but even after
30-40 mins, nothing happens.
I dont get an error, seg fault or out_of_memory exception.
You need to process the document as a stream of elements; aka SAX.
IMHO, this is the worst advice you can give.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
examples that will help you here.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ST NOT be declared as the default
namespace.
"""
http://www.w3.org/TR/REC-xml-names/#ns-decl
lxml knows about this special case, so you can write
{http://www.w3.org/XML/1998/namespace}lang
and lxml will take care of using the right prefix.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Steve Holden, 25.12.2010 16:55:
On 12/23/2010 4:34 PM, Stefan Sonnenberg-Carstens wrote:
For large datasets I always have huge question marks if one says "xml".
But I don't want to start a flame war.
I agree people abuse the "spirit of XML" using it to transfer g
he storage
layout before hand.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Tim Harig, 26.12.2010 10:22:
On 2010-12-26, Stefan Behnel wrote:
Tim Harig, 26.12.2010 02:05:
On 2010-12-25, Nobody wrote:
On Sat, 25 Dec 2010 14:41:29 -0500, Roy Smith wrote:
Of course, one advantage of XML is that with so much redundant text, it
compresses well. We typically see gzip
Jim, 26.12.2010 00:32:
On Dec 25, 5:33 am, Stefan Behnel wrote:
lxml knows about this special case, so you can write
{http://www.w3.org/XML/1998/namespace}lang
and lxml will take care of using the right prefix.
Stefan, thank you for the software, which has helped me a great deal
Alan Meyer, 27.12.2010 21:40:
On 12/21/2010 3:16 AM, Stefan Behnel wrote:
Adam Tauno Williams, 20.12.2010 20:49:
...
You need to process the document as a stream of elements; aka SAX.
IMHO, this is the worst advice you can give.
Why do you say that? I would have thought that using SAX in
inary format
that stores the above information in 1 bit.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Alan Meyer, 28.12.2010 03:18:
By the way Stefan, please don't take any of my comments as complaints.
I don't. After all, this discussion is more about the general data format
than the specific tools.
I use lxml more and more in my work. It's fast, functional and pretty
Alan Meyer, 28.12.2010 01:29:
On 12/27/2010 4:55 PM, Stefan Behnel wrote:
From my experience, SAX is only practical for very simple cases where
little state is involved when extracting information from the parse
events. A typical example is gathering statistics based on single tags -
not a very
le is, well, new, it will
not be equal (read: identical) to any cached tuple, thus resulting in a new
entry regardless of its content.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
assume "rml_accept" is the real name of the attribute?
You may be able to do this with a look-ahead expression, e.g.:
replace = re.compile('(wrong_tag\s*=\s*[^>=]*)(?=>|\s+\w+\s*=)').sub
html_data = replace('', html_data)
The trick is to match everything up to the next character that looks
reasonable again, i.e. a closing tag character (">") or another attribute.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Jorgen Grahn, 30.12.2010 10:41:
If you really *do* have a requirement to make the result XML-like and
incompatible with anything else, I'm afraid you're on your own
Well, there's always xmlsec if you need it.
http://www.aleksey.com/xmlsec/
Stefan
--
http://mail.python.org/m
it.
http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/
(the site is currently broken for me, you can use the following instead:
http://webcache.googleusercontent.com/search?q=cache:WsGrJKw6ABoJ:www.cosc.canterbury.ac.nz/greg.ewing/python_gui/
Stefan
--
http://mail.python.org/mailman/listi
rantingrick, 30.12.2010 17:02:
On Dec 30, 9:52 am, Stefan Behnel wrote:
I hope you invested as much time into writing this "expose" as you did
searching the web before writing it.
in my second post i said...
"""However i need to stress that my intention is towards
e somewhere?
ftputil will do most of these tasks easily. For step 4
you probably want to use Python's fnmatch module, see
http://docs.python.org/library/fnmatch.html .
If you have questions on ftputil, there's also a
mailing list:
http://ftputil.sschwarzer.net/trac/wiki/MailingLi
so older Python versions will
consider it a syntax error.
To support older Python versions, you need to write your own wrapper
functions for bytes literals that do nothing in Python 2 and convert the
literal back to a bytes literal in Python 3. That's ugly, but there's no
other way to do it.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
his topic. You need to
wrap the literal in a function call that converts it to a bytes literal
when running in Python 3.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Baptiste Lepilleur, 01.01.2011 12:53:
2011/1/1 Stefan Behnel
Baptiste Lepilleur, 01.01.2011 10:01:
I'm trying to port a small library to Python 3.x, and I'm wondering what
is the best way to port statements such as the one belows that are
frequently found in network protocol impl
ings out of the immediate
sight of someone reading the sources, and that it requires the two string
modules to be kept in sync. But at least for the synchronisation, a
simplistic conversion tool run during installation could do the trick.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
create a sibling for?
if subElem == elem:
There is an .index() method on Elements that does what you want to achieve
here. However, the right way to do it is to use ".addnext()".
http://codespeak.net/lxml/api/lxml.etree._Element-class.html
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
lder Python versions and
PyCapsule in Py2.7 and Py3.1+.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Stefan Sonnenberg-Carstens, 06.01.2011 07:08:
Am 05.01.2011 23:44, schrieb Rohit Coder:
I am just asking. In future I may need to import any C++ library, not a
Crypto, but some other. Is it possible?
Yes.
There are at least five possible ways:
- Handcode the interface and glue code (http
urces.
Objects within a reference cycle will eventually get cleaned up, just not
right away and not in a predictable order.
If you need immediate cleanup, you should destroy the reference cycle
yourself, e.g. by removing the widgets from the dialog when closing it.
Stefan
--
http://mail.pytho
aefa00fef
cdecimal-2.2-no-thread.win-amd64-py2.7.msi
413724ff20ede7b648f57dd9a78a12e72e064583
cdecimal-2.2-no-thread.win-amd64-py3.1.msi
Stefan Krah
--
http://mail.python.org/mailman/listinfo/python-list
moerchendiser2k3, 10.01.2011 22:19:
On Jan 10, 7:18 pm, Stefan Behnel wrote:
moerchendiser2k3, 10.01.2011 18:55:
If you can tell us why it's so important that the object be destroyed
at that given time, even while a reference to it exists, maybe we can
give you better suggestions.
T
SANKAR ., 11.01.2011 01:00:
I am reading a Test.txt (see atatchment) file using following code to get
the T2:
F =open('C:\Test.txt','r')
T1 = F.readlines()
for i in range(len(T1)):
T2 = T1[i].split(',')
print(T2)
Take a look at the "csv"
mand$(: # comment1
)-sw1 $(: # comment2
)-sw2 $(: # comment3
) arguments
-- Stefan
--
http://mail.python.org/mailman/listinfo/python-list
question at hand and has no point other than polluting people’s
mailboxes.
http://www.catb.org/~esr/faqs/smart-questions.html#beprecise
http://www.catb.org/~esr/faqs/smart-questions.html#volume
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
would have helped in answering.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
1601 - 1700 of 2239 matches
Mail list logo