rom a C++ background, you will happily appreciate
how simple programming can be. You will also appreciate learning about
Cython, which is the straight forward way for you to write Python code that
interfaces with C++ natively.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
x27;t tell
anything about the skill level of 'the average' JavaScript developer wrt.
functional techniques.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
hon for purposes of rapid developement
and too slow to be competative for non-long-lived tasks.
So seriously need to take a look at Cython.
http://cython.org
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
.
Canonical answers: cElementTree and lxml.
The first, if you want to use stdlib tools, the second, if you can afford
external dependencies.
Both are mostly compatible, very fast and memory friendly. lxml has lots of
features in addition.
Stefan
--
http://mail.python.org/mailman/listinfo/python
lxml.etree. That should get
you going.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
y
for you.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
cy is done automatically, and Go code doesn't run natively on
Windows either, without first installing and running the compiler over it.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
hat I never found CPython's startup time to be slow, quite the
contrary.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten, 18.01.2011 10:04:
What's the advantage of 'find ... | xargs ...' over 'find ... -exec ...'?
The former runs in parallel, the latter runs sequentially.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
up with an
orphaned .pyc file, right now and as it was for the last 21 years. The same
applies to the new cache directory.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Octavian Rasnita, 19.01.2011 07:10:
aren't the Pyton bytecode-compiled files considered secure enough?
Can they be easily decompiled?
Yes.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Octavian Rasnita, 19.01.2011 11:31:
From: "Stefan Behnel"
Octavian Rasnita, 19.01.2011 07:10:
aren't the Pyton bytecode-compiled files considered secure enough?
Can they be easily decompiled?
Yes.
FYI, just take a look at the 'dis' module. There are also decompil
Tim Harig, 18.01.2011 12:37:
On 2011-01-18, Stefan Behnel wrote:
Tim Harig, 17.01.2011 20:41:
I prefer a single language as opposed to a creolization of two.
With the possible exception of Lisp, I find it hard to think of a language
that's still alive and not the creolisation of (at
t having a rock solid maintainer for both of them is not going to happen.
Are you volunteering to maintain both wxPython and wxWidgets in the
standard library for, say, twenty years to come?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
e
the ElementTree API, commonly the findtext() and findall() methods of the
root object, to get at the specific record fields. Like this:
for _, element in ET.iterparse(fileobject):
if element.tag == 'xml_record_tag':
title_name = element.findtext('
Stefan Behnel, 26.01.2011 10:29:
Johann Spies, 26.01.2011 10:07:
I an not a Python newbie but working with xml is new to me.
I get data through a soap connection, using suds, and want to convert that
to objects which I can use to populate a rather complex database.
Your problem description
Johann Spies, 26.01.2011 13:22:
On 26 January 2011 12:51, Stefan Behnel wrote:
The example you sent me is almost perfect for lxml.objectify. Basically,
you'd do something like this:
Thank you very much. You have helped me a lot.
You're welcome. If you have any suggestions how
XML after the fact. The only advice I can give: be careful with
the default namespace.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
cana--tA
f.
voluntary_poverty_as_practised_by_JainajEna_ascetics.
000177 2,2 272
I've found that there is the library python-dictdlib for concatenating dict
dictionaries, what would
be the best way to "de-XML" the source file?
How do you want to the dict to look like?
Stefan
27;, 'H3')
for _, element in iterparse('thefile.xml'):
if element.tag in h_tags:
words[element.findtext('h/key1')] = element
Since you didn't provide enough information, I have no idea what you want
to make of the "h", "body" and "tail" tags. But I'm sure you'll figure it out.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
val(java_script_code))
Although I'd simplify the JavaScript code somewhat to make it a plain
expression.
If that's not what you want, please be more precise, or look at the CSS
selectors in lxml that Jon Clemens pointed you to.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
to insert the super class struct here, not a plain new object struct.
In case you want to avoid stumbling over problems like this and instead
concentrate on getting functionality implemented, take a look at Cython.
http://cython.org
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
t;. But I must say that I rarely read either of the two being
used as common meanings for "practicality" on python-dev. That term is very
user focussed in the Python community.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Bob Martin, 07.02.2011 08:19:
My two terriers absolutely love children.
H, tasty ...
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
or something as generic as an XML parser.
What may work for you is to check if an Element has children and only
whitespace as text ("not el.text or not el.text.strip()"), and only then
replace it by None.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
in UTF-8.
Parse from a byte string instead, as you do in your fixed code.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
cygwin, it was likely due to the heavy lifting
cygwin does in order to emulate fork() on Windows.
http://www.cygwin.com/faq/faq-nochunks.html#faq.api.fork
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
f._parser.SetBase(source.getSystemId())
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in
position 0: ordinal not in range(128)
The open(..) part works fine, but there still seems to be a problem inside the
sax parser.
Did you read my reply?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Stefan Behnel, 09.02.2011 09:58:
Rickard Lindberg, 09.02.2011 09:32:
On Tue, Feb 8, 2011 at 5:41 PM, Chris Rebert wrote:
Here is a bash script to reproduce my error:
Including the error message and traceback is still helpful, for future
reference.
Thanks for pointing it out.
#!/bin/sh
.
And I agree with Chris Rebert that you should open a bug against the sax
package in Python 2.7 on the bug tracker.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Williamson, Ross X. wrote:
I'm trying to implement a server/client system where the server is written in
python and the client has to be written in c/c++.
Is this a strict requirement? Could you give us a hint why the client needs
to be plain C/C++?
Stefan
--
http://mail.python.org/ma
1780339444980186test
you can notice that there is no tab between a_id and s
Likely just a presentation problem in your terminal. Try with a single
space instead of tabs and see the difference.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
result are both the same.
What happened to str.join?
thanks
I'm sorry, I found it should be the terminal width caused visual
problem, please kindly ignore this post.
Well, there's always this that's worth remembering:
http://www.catb.org/~esr/faqs/smart-questions.html#id478549
S
ium.get_eval(self, java_script_code))
#return int(selenium.getEval(java_script_code))
You want to use "self.selenium" here, not "selenium".
Stefan
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost&q
SMERSH009, 18.02.2011 07:25:
On Feb 17, 9:51 pm, Stefan Behnel wrote:
SMERSH009, 17.02.2011 22:46:
class Untitled(unittest.TestCase):
def count_css_matches(self, css_locator):
java_script_code = '''
var cssMatches = eval_css("
would explain the
32bit truncation.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
bit naive to me.
It's correct that all compile time information about function signatures is
gone in the library. So you must provide ctypes with the exact signature to
allow it to convert your input and output data correctly, and to put the
values on the call stack in the correct callin
ave the proper function
> signature.
I suggest that you reconsider, since this appears to work:
def from_param(self):
return ctypes.c_void_p(self.c_ptr)
Stefan Krah
--
http://mail.python.org/mailman/listinfo/python-list
has a critical bug in distutils that
prevents .pyc files from being byte compiled to their proper location
during installation, thus preventing them from being used.
http://bugs.python.org/issue11254
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ixes are available?
You mean: as soon as someone writes a fix?
I want to know if I should be on the lookout for a better version of 3.2.
Better test now and report any problems you find. (Actually, that's what
the beta/RC phase was there for, but it's never too late to find a bug.)
sed solution, both for
performance and maintainability reasons.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
hich is close to the same thing.
Hmm, right, good call. There's also the configparser module in the stdlib
which may provide a suitable format here.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
that to
parser = objectify.makeparser(ns_clean=True, remove_comments=True)
root = objectify.parse(inputfile,parser)
Change that to
root = objectify.parse(inputfile,parser).getroot()
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
lz -lcrypt -lm -o
> >> build/lib.freebsd-7.0-RELEASE-i386-2.7/_mysql.so
> >> gcc: ${LDFLAGS}: No such file or directory
> >> error: command 'gcc' failed with exit status 1
> >
> > where should I be looking to fix this problem?
Try the patch from http://bugs.python.org/issue10547 or use an svn checkout.
The patch didn't make it into 2.7.1.
Stefan Krah
--
http://mail.python.org/mailman/listinfo/python-list
Matt Funk, 21.02.2011 23:40:
On 2/21/2011 3:28 PM, Stefan Behnel wrote:
Matt Funk, 21.02.2011 23:07:
thank you for your advice.
I am running into an issue though (which is likely a newbie problem):
My xml file looks like (which i got from the internet):
Gambardella, Matthew
suits your needs.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
e
an XSLT before hand. CSS is for layout (headings, tables, positioning
etc.), XSLT is only needed when you require major structural changes or
format conversions, which likely won't be necessary here.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
mp.append(fiyat)
combinations.append(temp)
For this kind of computation, Cython is usually much faster than NumPy by
itself.
http://cython.org/
http://docs.cython.org/src/tutorial/numpy.html
http://docs.cython.org/src/userguide/numpy_tutorial.html
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
table release" (that would be 2.3), but at least one
that's pre-built for Windows.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ython
Maybe not quite what you asked for, but given the names in the example
above I would call this an ontology.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
basically impossible to beat the speed of (f)grep.
I'd use the subprocess module to run zfgrep over the file and parse the
output in Python.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Mag Gam, 08.04.2010 14:21:
On Thu, Apr 8, 2010 at 7:31 AM, Stefan Behnel wrote:
Mag Gam, 08.04.2010 13:21:
I am in the process of reading a zipped file which is about 6gb.
I would like to know if there is a command similar to grep in python
because I would like to emulate, -A -B option of
omnia neo, 09.04.2010 07:01:
import siptest
I get following error :
import error : no module named siptest
Is the directory where your siptest.dll lies in your PYTHONPATH (sys.path)?
Otherwise, Python can't find it.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
plain about problems that are easy to solve
with the solution at hand.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
me.compile("{^g.?+*y:h}|\Y^r&(?P:2+)|\w+(x&y)|[?#\s]").solve()
Actually, I would expect that the result of any mathematical calculation
can be found by applying a suitable regular expression to pi.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
ity of two lists. If you want to influence the equality, you need to
override __eq__. If you don't, the original implementation is free to do
whatever it likes to determine if it is equal to another value or not. If
it uses __len__ for that or not is only an implementation detail that can't
be relied upon.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
e commands manually, even if you can. It's perfectly ok to write the
program in Python instead.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
u describe why you want such a language in the first place? What
feature do you need that cannot be expressed using doctests, for example?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
#x27;, 'utf-16').read())
"u'a\\n\\nb\\n\\n'"
of course, the output i want is:
"u'a\\nb\\n'"
i suppose it's not too surprising that the built-in open converts the
line endings before decoding, but it surprised me that codecs.open does
this as well.
The codecs module does not support universal newline parsing (see the
docs). You need to use the new io module instead.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
to about 45 seconds.
What is the reason of this improvement?
Local variables in a function can be accessed much faster than globally
defined names (which require a dictionary lookup). This is a good thing
because the access to local variables tends to be much more performance
critical than
Hannes, 12.04.2010 12:56:
I heard that its possible to use LLVM to speed up Python.
Can anybody explain to me, how that works?
http://code.google.com/p/unladen-swallow/
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
s of other options, as already pointed out.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
open()
function for that).
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Chaim Krause, 13.04.2010 17:26:
I am building a web page (HTML 4.01 Transitional) using
xml.dom.minidom. I have created a
help me with this?
E.g. using lxml.html:
import lxml.html as H
html = H.parse("the_html_file.html")
print H.tostring(html, method="text")
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
e way
to go"?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Emile van Sebille, 14.04.2010 15:24:
On 4/13/2010 11:43 PM Stefan Behnel said...
rake, 14.04.2010 02:45:
On Apr 13, 2:12 pm, Chris Colbert wrote:
You should look into beautiful soup
http://www.crummy.com/software/BeautifulSoup/
For more complex parsing beautiful soup is definitely the way
want to tell us what that job is, so that we can point you to a
suitable tool.
Usually, parsing is only one part of a program that deals with XML.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Shashwat Anand, 15.04.2010 11:55:
> BeautifulSoup
The OP asked for an XML parser.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Shashwat Anand, 15.04.2010 12:29:
On Thu, Apr 15, 2010 at 3:50 PM, Stefan Behnel wrote:
Shashwat Anand, 15.04.2010 11:55:
BeautifulSoup
The OP asked for an XML parser.
BeatifulSoup can be used as one IMO
But it is not an XML parser according to the XML spec. So giving the
impression
t's also in the stdlib. If you need more powerful features,
take a look at lxml.etree, which is a (mostly) compatible external package.
> By the way, besides is there any great book for
> learning python?
That has been answered many times on this list. Check the archives, or look
through th
with the "any"
builtin than with the "sum" builtin.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
pca, 16.04.2010 22:02:
On Apr 16, 8:28 pm, Stefan Behnel wrote:
pca, 16.04.2010 17:18:
In fact, I have seeded an open-source project, Yoopf, that enables
programming by formula within Python, with the goal of dramatically
accelerating the development of the model view in the MVC model
first. The latter will read all
lines into a big list in memory before doing any further processing,
whereas the plain for-loop will read line by line and let the loop body act
on each line immediately.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
thing in the first
place).
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
since you mention that you "often" find yourself
doing the above, you may also have a mental design problem somewhere. We
can't tell unless you provide a more concrete example than what you show above.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
decs.open() in favour of
f = open("foo.xml", "wb")
(mind the 'b' in the file mode, which stands for 'bytes' or 'binary')
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
; a+=l; a+=l"
1 loops, best of 3: 151 usec per loop
$ python2.6 -m timeit -s "l=range(1)" \
"a=l[:]; a.extend(l); a.extend(l)"
1000 loops, best of 3: 164 usec per loop
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
to write to the same
file, and doesn't rely on any specific coordination between those two
interfaces.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
child_nodes.childNodes)
By convention, the underscore at the beginning of "_get_childNodes"
indicates that it is not considered a public method.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
al/decarith.pdf
> (to-engineering-string is on page 20 if you're interested)
The module is correct. Printing without exponent follows the same rules
as to-scientific-string:
"If the exponent is less than or equal to zero and the adjusted exponent
is greater than or equal to -6,
.2/decimal.py", line 3836, in _raise_error
raise error(explanation)
decimal.InvalidOperation: Invalid literal for Decimal: 'wrong'
>>>c.traps[InvalidOperation] = False
>>> Decimal("wrong", c)
Decimal('NaN')
Stefan Krah
--
http://mail.python.org/mailman/listinfo/python-list
mailing list (you might
want to search the archives). The main theme seems to be that clang
provides a suitable parser, and several people have used it to write up a
code generator for their specific needs (you might want to look at those).
Stefan
--
http://mail.python.org/mailman/listinfo/python
f
your way another little bit more than Py2. It's also less outdated cruft to
talk about, e.g. old-style classes are gone, unicode issues are mostly gone
or at least easier to explain (and worth explaining when they occur). It's
just more fun to work with. :)
Just my two €-cents.
Yingjie Lan, 28.04.2010 05:53:
From: Stefan Behnel
Yingjie Lan, 27.04.2010 08:30:
Is it possible to use SWIG to parse C/C++, and provide
an interface for
me to generate some code? I thought it might be good
to have SWIG help
generate expy files, then generate the python
extension via expy
?
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
than this?
Try one of the dbm modules in the stdlib. They give you dictionary-like
lookups on top of a persistent database.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
large files
I seriously doubt that they do.
(first cElementTree
adds them, then I have to remove them in python).
I think that's your main mistake: don't remove them. Instead, use the fully
qualified names when comparing.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
he above code and remove the need for a
global variable.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
def SomeOtherFunction(self):
self.Data.something()
It's an ugly way to implement a pointer or something like it. What is the
right way?
Cheers
Stefan Krastanov
P.S. Maybe it's bad idea to use two different view classes, but that is
another question.
P.P.S. Maybe I'm breaking the
ntax changes will be accepted for at least 24
months starting from the release date of Python 3.1. See more details
here: http://www.python.org/dev/peps/pep-3003/
In any case, the right place to discuss this is the python-ideas list.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
s me desired tags without stinking
URIs.
You should try to calm down and embrace this feature.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
Carl Banks, 01.05.2010 12:33:
On Apr 29, 10:12 pm, Stefan Behnel wrote:
dmtr, 30.04.2010 04:57:
I don't want these "{http://www.very_long_url.com}"; in front of my
tags. They create performance disaster on large files
I seriously doubt that they do.
I don't know what k
64bit system, versus
1 byte per character in a byte string list. Depending on the ratio of
branches to characters, one or the other may win. So a "naive approach"
likely won't work for tries either.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> l = [1,2,3]
>>> a = l
>>> l += [4,5,6]
>>> l
[1, 2, 3, 4, 5, 6]
>>> a
[1, 2, 3, 4, 5, 6]
And I'm pretty sure this wasn't just done for performance reasons. Mutable
data types behave that way.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
st keeping subsequent discussion there.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
because it has excellent GUI (the quality of which is amazing).
See? Explanations help more than bold statements.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
al library wrappers.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
s. It
has been subject to serious benchmarking and optimisations.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
o ignore the invalid characters.
Could you suggest a way to call ElementTree, so it won't bomb on these
invalid characters ?
No. The parser in lxml.etree has a 'recover' option that lets it try to
recover from input errors, but in general, XML parsers are required to
reject non w
1701 - 1800 of 2239 matches
Mail list logo