er served with one of the dbm databases that come with
Python. They live on-disk but do the usual in-memory caching. They'll
likely perform a lot better than your OS level swap file.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
#x27;)
> TypeError: descriptor 'replace' requires a 'str' object but received a
> 'unicode'"
>
> How can I solve this?
By using unicode.replace() instead of str.replace(), i.e.
Omschrijving = Omschrijving.replace("priv?", 'privé')
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Jaap van Wingerde wrote:
> Stefan Behnel wrote:
>> Omschrijving = Omschrijving.replace("priv?", 'privé')
actually, make that
Omschrijving = Omschrijving.replace(u"priv?", u'privé')
(mind the u"...")
>
> import c
r caching?
> BTW, the target platform is Linux.
Their interfaces are mostly compatible to Python dicts. Just keep your code
independent at the beginning and benchmark it against all of them.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
> What does the S stand for?
The S stands for simple.
http://wanderingbarque.com/nonintersecting/2006/11/15/the-s-stands-for-simple/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
he more
general interest appears to be spreading controversial topics over a vast
number of newsgroups.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
7;d use gdb for debugging these things. It does have a
learning curve, but in change gives you a lot more than just "print-debugging".
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> Stefan Scholl a écrit :
>> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>>> On Nov 19, 1:50 am, gavino <[EMAIL PROTECTED]> wrote:
>>>> what is nicer about each?
>>> Yes.
>>
>> And
eme lisp, Emacs lisp, PHP?
Think before you write. It's exactly the same thing. How would you get all
Emacs users in the world to upgrade?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
e of returning None, where
it would now return an empty list.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ons that are
not worth testing due to obvious triviality, is pretty hubristic.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
e talking about two completely unrelated things:
reloading code into the Python interpreter, and keeping track of changes in
the development of code.
I think what you have in mind is that smaller changes make code reload
easier than bigger changes, especially API changes.
Stefan
--
http://mail.p
Stefan Behnel wrote:
> I think what you have in mind is that smaller changes make code reload
> easier than bigger changes, especially API changes.
... or ABI changes in the general case, although that's not a major
difference in the Python context.
Stefan
--
http://mail.python.
,2,3]
>>> zip(l,l)
[(1, 1), (2, 2), (3, 3)]
>>> zip(*zip(l,l))
[(1, 2, 3), (1, 2, 3)]
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
st, tuple))
else list(some_iterable)))
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
;, kwlist,
> &PyFunction_Type, &hook))
> return NULL;
You have to release the GIL around the following function call, so that the
thread above can acuire it while you wait for the function to return in
this thread here (which I assume you do).
> LONG ok
xtension type that inherits from its C
equivalent at the C level. I assume that psyco does something similar here.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
mathematics is
> a notation.
>
> And mathematics, too, is a predominantly functional, not a procedural,
> notation. Could that be why so many people are frightened of functional
> constructs, like my code example and things like lambdas? Because they look
> too much like mathe
David Cournapeau wrote:
> I want faster function
> calls to use with numpy: do you know of any solution ?
http://cython.org/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
, but translate directly to fast pointer
> arithmetics.
http://docs.cython.org/docs/numpy_tutorial.html
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
o reduces the amount of memory
handling you have to care about.
http://cython.org/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
on byte strings is 0 terminated, so
strlen() will work.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
st byte strings I've seen didn't, though. And if you know
that they don't contain any null bytes (UTF-8 serialised XML, for example,
or ASCII encoded text, or ...), 's' is just fine. If you need content *and*
length, use 's#'. Matter of use case, as usual.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
eaker: is this now valid english?
>
> "One of Python’s great strengths"
> ^
> "and also teaches Python’s functional programming features"
> ^
> "The book’s approach is wholly practical"
>^
first reaction was to
recognise how stupid you'd have to be to make that a static method that
ignores the string it's called on. :)
I think '...'.format() makes sense given that we already have '...'.join().
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
to
free the GIL or not.
> And while we are at it :-) Is "PyArg_Parse('[syz]*'..." the only way to
> get a locked buffer-view from string/byte objects?
What kind of locking do you need?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Mark Thomas wrote:
> The main difference is that lxml doesn't have CSS selector syntax
Feel free to read the docs:
http://codespeak.net/lxml/cssselect.html
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
like chardet:
http://chardet.feedparser.org/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
e web. Does Python have anything similar, i.e.
> something that will not only do XPath queries, but will do so on
> imperfect HTML?
lxml.html is your friend.
http://codespeak.net/lxml/lxmlhtml.html
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
akineko wrote:
> The more you work on Python, the harder you can go back to C or C++
> world.
>
> I use SWIG, instead. I think SWIG is a good way to mix two worlds.
If you find it hard to go from Python back to C, you should have a look at
Cython.
http://cython.org/
St
rver I think you
> have to rely on the ZSI (http://pywebsvcs.sourceforge.net/)
> project. In retrospect my first steps in this library were rather
> painful but som year ago it was the most sophisticated library.
Use soaplib (for client and/or server), it's a lot less painful.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
eleases). However, I'd recommend Cython instead, as it gives
you very fast and portable code that works with all CPython versions. And
Cython code is not any harder to write at all.
http://cython.org/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
t; Mechanize. I could also use DB.
> Has there been any word on Beautiful Soup?
At least for new code, you can use lxml instead. Being written (mostly) in
Cython, it compiles and works in Py3.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ok at lxml.objectify. Note that it's only partially
compatible with ElementTree, so you will have to change your code (lxml.etree
is mostly compatible, but it doesn't support pickling). It's a very
easy-to-use XML library, though.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
st. In case you come
to the conclusion that reimplementing Python is too big for a final year
project, you might as well find a couple of good ideas in Cython's list of
potential enhancements. Check the Wiki.
http://cython.org/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
fault"
Consider using Cython instead, it will make your life a lot easier. The above
is valid Cython code that the Cython compiler translates into optimised C code.
http://cython.org/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
quot;node":
print el.tag
which works in both ET and lxml.etree.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ready? Maybe you
meant Windows 1.0?
SCNR-ly,
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
t;
> Why do they differ?
The browser sends a different client identifier than urllib, and the server
sends back different page content depending on what client is asking.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
>
There's a drop_tag() method in lxml.html (lxml/html/__init__.py) that does
what you want. Just copy the code over to your code base and adapt it as needed.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
omes that they are willing to answer you.
There are a lot of projects out there that might make an interesting starting
point for you. Check PyPI.
http://pypi.python.org/pypi?%3Aaction=browse
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
asit wrote:
> what is XML-RPC System
Doesn't Wikipedia tell you that?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ng to parse:
> elognormal text
>
> Output:
> [[['elog', 'normal text']]]
You should try lxml.html. It gives you various tools like XPath to look for
specific elements and helper functions to find the links in an HTML document.
http://codespeak.net/lxml/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
rseError: bad end tag: "", at
> line 515, column 45
Your HTML page is not HTML, i.e. it is broken. Python's HTMLParser is not made
for parsing broken HTML. However, you can use the parse of lxml.html to fix up
your HTML for you.
http://codespeak.net/lxml/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Peter Pearson wrote:
> Like you, I struggle with BeautifulSoup
Well, there's always lxml.html if you need it.
http://codespeak.net/lxml/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ile)
> for f in unzip.namelist():
> if f.endswith('.xml'):
> output.write(unzip.read(unzip))
> xmlfiles.append(output.getvalue())
>
> sftp.close()
> ssh.close()
I suppose this code doesn't work for you? What's the output you get?
"don't seem to be able" is not a very helpful problem description.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ding="utf-8". That way,
when it's not UTF-8, you will get an exception at parse time, which allows you
to reparse the document with another encoding (say, ISO-8859-1) to get the
correct content.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Dejan Pangercic wrote:
> question is, does anyone know about any up2date equivalent for
> connecting to WSDL from python?
It seems like you missed soaplib. Compared to other Python SOAP libraries,
it's pretty easy to use.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ely copy the attributes of your objects into the E factory of
lxml, either with generic code, or with specialised code for each (sub-)object.
http://codespeak.net/lxml/tutorial.html#the-e-factory
There's also a separate implementation for plain ElementTree (the xml.etree
package) by Fred
bslobodi wrote:
> [spam stripped]
Sorry, I didn't find comp.shit on Gmane. Did you mean comp.shell or something
in that line?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
I think I'd manage to write a web
> framework too - do you really think it would be a good idea to start
> writing another one?
I think Tino was more referring to the fact that state machines are too
trivial to write in Python to merit a whole framework.
http://www.google.de/search?q=python+state+machine
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
entertainment show was more expensive
than the average Marx-Brothers sketch).
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
bda x:(type(x),x))
> Traceback (most recent call last):
> File "", line 1, in
> TypeError: unorderable types: type() < type()
However, for an arbitrary ordering of types, id(type(o1)) <= id(type(o2)) will
work well enough.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
u need validation?
http://codespeak.net/lxml/validation.html
http://codespeak.net/lxml/objectify.html#asserting-a-schema
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
disutils.cfg should have the
> following lines)
>
> [build]
> compiler=mingw32
Not quite the perfect place to report this (the Cython mailing list would
have been just right), but thanks anyway.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
it into C code, and then benchmark that.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
collect[child.get('ValueId')] = child.get('value')
print "%s\t%s\t%s\t%s" % ((id,) + tuple(
collect[key] for key in ['name','description','image']))
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> On Nov 19, 1:50 am, gavino <[EMAIL PROTECTED]> wrote:
>> what is nicer about each?
>
> Yes.
And No.
--
http://mail.python.org/mailman/listinfo/python-list
on a try.
http://cython.org
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
y smaller
> (about 2**30).
Which, in practice, means that the size is limited by the available memory.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ta are lines of a file, and keeping the original order isn't
> important, then the first to try may be to use the unix (or cygwin on
> Windows) commands sort and uniq.
or preferably "sort -u", in case that's supported.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
eed to parse this html_source file, at client side. Is there
> a module to handle this? Can somebody help? Thanks!
lxml.html has good form handling support:
http://codespeak.net/lxml/lxmlhtml.html#forms
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
fredbasset1...@gmail.com wrote:
> I'm writing a C extension for Python, is it possible to define
> constants in the C code and have them visible from Python?
Have you looked at Cython? It allows you to define e.g. enums as "public"
and will generate the rest for you.
http
use someone shows me benchmark results of some code
that I absolutely don't need in my daily work.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Isaac Gouy wrote:
> On Mar 1, 8:10 am, Stefan Behnel wrote:
>> As long as that gives you improvements of
>> 100-1000 times almost for free, I wouldn't bother too much with changing
>> the platform just because someone shows me benchmark results of some code
>> th
Isaac Gouy wrote:
> On Mar 1, 11:24 am, Stefan Behnel wrote:
>> Isaac Gouy wrote:
>>> On Mar 1, 8:10 am, Stefan Behnel wrote:
>>>> As long as that gives you improvements of
>>>> 100-1000 times almost for free, I wouldn't bother too much with changing
vangard of
the community don't like to use at least 2.6 for bridging to the future Python?
Is this the mutiny against the empery of the BDFL or is the vangard just asking
for some more time? If I want to attest my personal attachment to the king by
using 3.0, what will happen? Will I be deser
with the xml.etree package that
comes with Python2.5 and later (it's also avalable for older versions).
It's a lot easier to use, more memory friendly and also much faster.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ing to cElementTree before major code gets written is
almost certainly a good idea here.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
mentTree as the
(likely) shorter and more readable code (which usually translates into
shorter development and debugging times) and the higher execution speed.
Honestly, I haven't seen a reason in a while why preferring minidom over
any of the ElementTree derivates would be a good idea when st
b);
>
> how do I transfer the exc_type in a char* ?
Are you sure you want the exc_type and not the exc_value? The only major
thing I'd do with the type of an exception is to let Python check for it
using PyErr_ExceptionMatches().
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
BigHand wrote:
> Finally I got the results now. This did take me 10 hours to solve
> this. the docs of 3.0..
You will have to get used to Unicode. The code you used against the C-API
mimics almost exactly the steps you'd use at the Python level.
Stefan
--
http://mail.python.
This thread is
about unallowed characters in XML. The set of allowed characters is defined
here:
http://www.w3.org/TR/xml/#charsets
And, as Terry Reedy pointed out, the "unicode.translate" method should get
you where you want. Just define a dict that maps the characters that you
want
Flank wrote:
> can python import class or module directly from a zip package
Yes, just put the .zip file into your PYTHONPATH.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
these methods return
> ordinary strings instead of unicode. So sometimes I get str,
> sometimes I get unicode. Can one change this globally so that they
> only return unicode?
That's a convenience measure to reduce memory and processing overhead.
Could you explain why this is a prob
Torsten Bronger wrote:
> Hallöchen!
und zurück!
> Stefan Behnel writes:
>
>> Torsten Bronger wrote:
>>
>>> [...]
>>>
>>> My problem is that if there is only ASCII, these methods return
>>> ordinary strings instead of unicode. So s
hose *instead* of installing libxml2/libxslt
separately, or build lxml with the "--auto-rpath" option to make it
remember the path where the libraries were installed when it was compiled.
BTW, you do not need the Python bindings for those two libraries installed,
in case y
m its server, without
preventing other threads from receiving data from their server at the same
time. That should get your bandwidth usage up.
You may have to take care that you do not run too many threads against the
same server (which may get upset and block your requests, depending on the
site)
ha1.
Have fun,
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
t; My understanding is that we can replace our use of elmentree and
> htmlparser with lxml.
Yes, although the API of HTMLParser is different from lxml's own HTML
parser and tree interface (which is basically trivial).
> Congrats on your latest release!
Thanks!
Stefan
--
http://mail.p
0000): a += "A" '
real0m0.140s
user0m0.132s
sys 0m0.008s
Stefan
(BTW, this is using Python 2.5.2 on Ubuntu Linux etc.pp., but no-one's
interested in these details anyway, right?)
--
http://mail.python.org/mailman/listinfo/python-list
n many
aspects (as is Py2.6 compared to 2.5 or 2.4, BTW), so I think version
numbers matter a lot in this case.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
your
application independent of a particular web server (and testable even
without a web server).
If you want to do XSLT in Python, lxml is a very good choice:
http://codespeak.net/lxml/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
t; "Python.org")
>
> tabbed_file(mypage, open('myfile.html', 'w'))
See here for another example that uses lxml.html:
http://codespeak.net/lxml/lxmlhtml.html#creating-html-with-the-e-factory
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
; print result
>
> displays the entire document. To make use of the keyword options
> xml_declaration, pretty_print, encoding, I tried using the .write
> method of result to a StringIO but it produces the same clipped
> result. Guess Ill have to edit the .docinfo attributes on the result
> and return the string
.docinfo is basically read-only. The result of the XSLT is serialised as
requested by the xsl:output element in the stylesheet.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
;, so
> perhaps the SIG page could be updated.
>
> Is there a guide to porting projects that depend on PyXML to Python-2.6?
Depending on how large your project is (and how well you encapsulated the
XML code), a partial rewrite using ElementTree or lxml might be worth it.
You'
tell what you are getting is invalid XML.
> So I think the answer is "you can't do that".
>
> (cf: http://www.w3.org/TR/2004/REC-xml11-20040204/#NT-NameChar)
Yes, that is correct. You should check why you are getting this (i.e. who
sends you this) and have them fix it. There is nothing you can (or should!)
do on your side to work around this.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ok at Cython. It allows you to write C
extensions in a Python-like language, so all of the above become trivial, e.g.
cdef class MyExtensionType(object):
def __init__(self, bint some_c_bool):
print type(self) is MyExtensionType
print some_c_bool == 1
C
al language for wrapping external C libraries, and
for fast C modules that speed up the execution of Python code.
"""
If you want a fast wrapper module that is easy to write and maintain, while
having all the freedom to design the Python-level API the way you want, I
don't thi
that you can easily hand-tune to your
needs. You basically have all the freedom of the Python language with all
the freedom of the C language.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
hat you can import and
use from Python.
http://cython.org
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
bled python V3
That's the core problem. :) Like many other Python packages, Cython doesn't
currently run in Py3. You can run it in any Py2 version starting from 2.3,
and the code it generates will run on 2.3 through 3.1a1. But the Cython
compiler itself requires 2.x. This is being fixed up as we speak, and the
2to3 conversion tool works pretty well on the source by now, so there's a
fair chance that Cython 0.12 will run on Py3.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Daniel Molina Wegener wrote:
> * Every serilization is made into unicode objects.
Hmm, does that mean that when I serialise, I get a unicode object back?
What about the XML declaration? How can a user create well-formed XML from
your output? Or is that not the intention?
Stefan
--
h
Daniel Molina Wegener wrote:
> Stefan Behnel
> on Sunday 19 April 2009 02:25
> wrote in comp.lang.python:
>
>
>> Daniel Molina Wegener wrote:
>>> * Every serilization is made into unicode objects.
>> Hmm, does that mean that when I serialise, I get
10-20 years before Python on Parrot
reaches 2.7 feature completeness.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
for a couple of cases, Python unicode strings
are very inconvenient for serialised XML.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
many string conversion under libxml2, the program gets more
> slow performance by using a different encoding than the default encoding.
It's not that much slower, though.
http://codespeak.net/lxml/performance.html#parsing-and-serialising
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
t aware of the tradition of "April
>> Fools":
>>
>> http://en.wikipedia.org/wiki/April_fool
>>
>> Look at the date of the PEP and the status.
>
> Heck, just look at its number and mentally insert one slash or dash.
My first thought was that the PEP number
nd will generally increase the
performance of your binding, as it will require less calls for larger operations
in C space.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Stefan Behnel wrote:
> you might want to try to wrap it in a more Pythonic
> look&feel style, that wraps operations and use-cases rather than plain
> functions. That should make it easier to hide things like memory allocation
> and other C implementation details from users, an
1201 - 1300 of 2239 matches
Mail list logo