Re: Generating C++ code

2012-10-10 Thread Stefan Behnel
you need something more advanced straight away, I'd say go for Cheetah. In case you decide not to use a template engine at all, given that your input format is XML, consider using lxml to build up your code tree for you by using custom element classes. Then, generate the code recursively top-down

Re: Generating C++ code

2012-10-10 Thread Stefan Behnel
news on 2011/09/26, I'm not sure the project is still alive. For FLOSS projects, it's usually better to look at the revision history, which, in this case, names September 3 as last entry, *this* year. Pretty much alive, I'd say. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: delete xml elements - using xpath search

2012-10-15 Thread Stefan Behnel
section and section > from my xml, (because it has the word NC) but need to keep > > can someone point me to the correct direction, or code snippet Use the xml.etree.ElementTree module. Just parse() in the file, iterate over the nodes, use the findtext() method to search for

Re: Providing a Python wrapper to a C++ type.

2012-10-16 Thread Stefan Behnel
). http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html I agree with discouraging 1) in specific. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Providing a Python wrapper to a C++ type.

2012-10-16 Thread Stefan Behnel
is quite irrelevant once it has been running for a while. The distinction between embedding and extending, as the Python docs put it, is actually quite fuzzy when it comes to the actual code interaction. Note also that this isn't the use case here, the OP asked for wrapping a C++ type for use in P

Re: ElementTree Issue - Search and remove elements

2012-10-16 Thread Stefan Behnel
m/CCC/2011/06/13/CC}Rating";): >x = child.find('Rating').text > if child[1].text == 'NC': > print "found" >root.remove('TVEpisode') ? > tree.write('output.xml') The trick is to search for the parent node, then let your code find out if you need to remove it or not by traversing its subtree. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: ElementTree Issue - Search and remove elements

2012-10-17 Thread Stefan Behnel
maps each Element to its parent by traversing the tree once. Alternatively, use lxml.etree, in which Elements have a getparent() method and in which single parents are enforced (also by design). Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: isinstance(.., file) for Python 3

2012-11-08 Thread Stefan Behnel
try: read = file_or_string.read except AttributeError: data = file_or_string else: data = read() I'd rather go with one of the previous solutions, though. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python3.3 str() bug?

2012-11-09 Thread Stefan Behnel
e object you pass in using the "latin-1" encoding. Since a list is not something that is "encoded", let alone in latin-1, you get an error, and actually a rather clear one. Note that this is not specific to Python3.3 or even 3.x. It's the same thing in Py2 when you call the

Re: Python3.3 str() bug?

2012-11-09 Thread Stefan Behnel
ts that need more than just a call to str(), some kind of further preprocessing? There are so many ways to do something like this, and it's so straight forward to do in a given use case, that it's IMHO useless to even think about adding a "general solution" for this to the stdlib. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: How to install libxml2-devel and libxslt-devel in Windows ?

2012-11-10 Thread Stefan Behnel
r lxml rather than the plain libxml2/libxslt Python bindings and seeing that you don't fear installing software from arbitrary web pages, you should try this binary installer: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: A gnarly little python loop

2012-11-11 Thread Stefan Behnel
earch, page_nums) > valid_pages = itertools.takewhile(bool, pages) > tweets = itertools.chain.from_iterable(valid_pages) > return tweets I'd prefer the original code ten times over this inaccessible beast. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: xml data or other?

2012-11-19 Thread Stefan Behnel
r description text should be in a CDATA section. > http://en.wikipedia.org/wiki/CDATA#CDATA_sections_in_XML Ah, don't bother with CDATA. Just make sure the data gets properly escaped, any XML serialiser will do that for you. Just generate the XML using ElementTree and you'll be fine. Generating XML as literal text is not a good idea. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Python on Android (was: PyPy 2.0 beta 1 released)

2012-11-22 Thread Stefan Behnel
pyvideo.org/video/1443/erfahrungen-mit-py4a-sowohl-mit-sl4a-als-auch He's using it for teaching purposes. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Using Xpath to parse a Yahoo Finance page

2012-12-02 Thread Stefan Behnel
ot;Total Assets" part. > > This should work: > > list_row2 = doc2.xpath(u'.//td[strong[contains(text(),"Total > Assets")]]/following-sibling::td/strong/text()') Something like "contains(text(),"Total Assets")" is better expressed as "contains(.,"Total Assets")" because it considers the complete text content instead of just one text node. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: empty object from C

2012-12-07 Thread Stefan Behnel
# or whatever you use However, how you'd use it depends on your actual C code. Personally, I'd drop C and write all Python interaction in Cython. Makes these things way easier. Here are some longer examples: https://github.com/cython/cython/tree/master/Demos/embed https://github.com/cython/cython/tree/master/Demos/callback Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: What are the minimum requirements to get a job in?

2012-12-14 Thread Stefan Behnel
ou to do and to try out. So you get more by investing less. Not the worst choice IMHO. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Create xml with elementtree ET and xml escaping

2012-12-15 Thread Stefan Behnel
; XML with the escaping isn't valid XML. > > Of course I know it is not valid without escaping. But I need it only for > signing. I will recheck this if really the web service wants the data to be > signed as non escaped. If it expects non-XML, you should tell the owners of the

Re: Py 3.3, unicode / upper()

2012-12-19 Thread Stefan Krah
d, since ß does not occur at the beginning of a word. As far as I know, most Germans wouldn't even know that it has existed at some point or how to write it. Stefan Krah -- http://mail.python.org/mailman/listinfo/python-list

Re: Brython - Python in the browser

2012-12-21 Thread Stefan Behnel
or a > programer who wants to develop a web application and doesn't know Javascript. > Ultimately this means that the whole DOM API would be described without any > mention of Javascript, only with the Python API If that's your intention, then instead of coming up with something totally new, unpythonic and ugly, why not take the normal Python route and implement a subset of the ElementTree API? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Brython - Python in the browser

2012-12-21 Thread Stefan Behnel
html.builder import * > >>> snippet = DIV("Hello ", B("world")) > >>> etree.tostring(snippet) > 'Hello world' For which there even happens to be an ElementTree implementation available: http://svn.effbot.org/public/stuff/sandbox/elementlib/builder.py (It's not like I made this up ...) Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Brython - Python in the browser

2012-12-21 Thread Stefan Behnel
n concerns - it looks like useless code, which is totally different from what it does. So it basically uses magic side-effects as part of the design, which is never a good thing. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: proposal: Ellipsis in argument list

2013-01-12 Thread Stefan Behnel
3:16) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def f(*args): print(args) >>> f(34, ..., 43) (34, Ellipsis, 43) Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Thorough Python 2.7.3 Windows Build Documentation?

2013-01-17 Thread Stefan Krah
s in with the PGO build in 3.3. Stefan Krah -- http://mail.python.org/mailman/listinfo/python-list

Re: Thorough Python 2.7.3 Windows Build Documentation?

2013-01-17 Thread Stefan Krah
O builds > or not. I remember that some versions of Visual Studio silently completed the PGO build without actually having PGO capabilities. :) I think for VS 2008 at least "Professional" is needed, for VS 2010 "Ultimate". Stefan Krah -- http://mail.python.org/mailman/listinfo/python-list

Re: Thorough Python 2.7.3 Windows Build Documentation?

2013-01-17 Thread Stefan Krah
ne version behind the latest. I wouldn't attempt it. For Python 3.3 the conversion has been done and the diff was enormous. Stefan Krah -- http://mail.python.org/mailman/listinfo/python-list

Re: Vote tallying...

2013-01-18 Thread Stefan Behnel
ou don't normally care about the votes but read the comments frequently. It's just a matter of adding an indirection for things that you use less frequently and/or that you use in more than one place (not in your case, where comments and votes are unique to an article). You see, lots of options, even just using the stdlib... Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Vote tallying...

2013-01-18 Thread Stefan Behnel
e with any proprietary software that you link against GPL code. As long as you don't ship your code to someone else who doesn't have access to your source code, you're free to do whatever you like with it. That's usually the case when you deploy your software on your own servers, for example. Only if you distribute your software to other people, the GPL enforces that you give them your source code under the same license. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Is PyArg_ParseTuple necessary to parse arguments?

2013-01-22 Thread Stefan Behnel
e things in plain C. If nothing else, it saves you from having to put thoughts into reference counting and other common CPython C-API pitfalls. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: XML/XHTML/HTML differences, bugs... and howto

2013-01-23 Thread Stefan Behnel
re are several ways to do it. Python has a couple of external libraries available that are made specifically for generating markup incrementally. lxml also gained that feature recently. It's not documented yet, but here are usage examples: https://github.com/lxml/lxml/blob/master/src/lxml/tests/test_incremental_xmlfile.py Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Further evidence that Python may be the best language forever

2013-01-28 Thread Stefan Behnel
ented a web interface for the simulator that monitored and visualised its current state. They said it helped them with debugging. > What language was the web page hosted in? It comes up completely blank > for me. :) Yep, same here. Hidden behind a flash wall, it seems. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Cheat Engine In Python

2013-02-01 Thread Stefan Behnel
on? > I mean just the code not compiled ? Not sure what you mean. Are you maybe looking for an open-source project? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: String interning in Python 3 - missing or moved?

2012-01-24 Thread Stefan Behnel
tainly keep an attacker from having to figure out hash collisions in order to bring down a system. Sending *any* arbitrarily varied data would be enough then. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Libxml2 Python Manual

2012-01-24 Thread Stefan Behnel
n you're not using lxml? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I call super() in c extention ?

2012-01-26 Thread Stefan Behnel
that the C code that it generates from your Python code will be more efficient than what you'd write manually. Certainly more readable and maintainable. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: PyPI - how do you pronounce it?

2012-01-28 Thread Stefan Behnel
but am wondering what the most > normal pronunciation is. And am fully prepared for the possibility > that there is no one "most normal"! I think a more obvious way to call it would be "cheeseshop", but since that was tried and rejected, I'm all for making it "Pippi" officially. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: xhtml encoding question

2012-02-01 Thread Stefan Behnel
y_print=True, >encoding=out_encoding) >with open(filename,'wb') as f: >f.write(result) Use tree.write(f, ...) Assuming you really meant XHTML and not HTML, I'd just drop your entire code and do this instead: tree = etree.parse(in_path) tree.write(out_path, encoding='utf8', pretty_print=True) Note that I didn't provide an input encoding. XML is safe in that regard. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterate from 2nd element of a huge list

2012-02-01 Thread Stefan Behnel
'it = iter(l); next(it); all(it)' 1000 loops, best of 3: 935 usec per loop python3.3 -m timeit -s 'l=list(range(10))' \ -s 'from itertools import islice' \ 'all(islice(l, 1, None))' 1000 loops, best of 3: 1.63 msec per loop Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: xhtml encoding question

2012-02-01 Thread Stefan Behnel
Tim Arnold, 01.02.2012 19:15: > On 2/1/2012 3:26 AM, Stefan Behnel wrote: >> Tim Arnold, 31.01.2012 19:09: >>> I have to follow a specification for producing xhtml files. >>> The original files are in cp1252 encoding and I must reencode them to >>> utf-8.

[ANN] cdecimal-2.3 released

2012-02-02 Thread Stefan Krah
Hi, I'm pleased to announce the release of cdecimal-2.3. cdecimal is a fast drop-in replacement for the decimal module in Python's standard library. Blurb = cdecimal is a complete implementation of IBM's General Decimal Arithmetic Specification. With the appropriate context parameters, cdec

Re: [ANN] cdecimal-2.3 released

2012-02-03 Thread Stefan Krah
For C, I think the why3 tool should be a good approach: http://why3.lri.fr/ The verification of the L4 kernel allegedly took 30 man-years, so it might take a while... Stefan Krah -- http://mail.python.org/mailman/listinfo/python-list

Re: Fabric Engine + Python benchmarks

2012-02-10 Thread Stefan Behnel
x.html Not sure which went first, but since you mentioned that you're "releasing soon", you may want to stop the engines for a moment and reconsider the name. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python usage numbers

2012-02-11 Thread Stefan Behnel
computation d) testing (non-Python/embedded/whatever code) I'm sure others will manage to remind me of the one or two I forgot... Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: XSLT to Python script conversion?

2012-02-13 Thread Stefan Behnel
d differences (currently I am using xsltproc)? Any > thoughts? You could try switching to lxml. It would at least allow you to do a part of the processing in Python and only use XSLT when it seems more appropriate and/or easier. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Complexity question on Python 3 lists

2012-02-15 Thread Stefan Behnel
hat would be an > implementation detail in any case. Absolutely. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating class definitions at runtime in memory from XSD or JSON

2012-02-17 Thread Stefan Behnel
Stodge, 17.02.2012 02:15: > Does anyone know of a library to generate class definitions in memory, > at runtime, from XSD or JSON? The question is: why do you want to do that? There may be other ways to do what you *actually* want to do, but we don't know what that is. Stefa

Re: XSLT to Python script conversion?

2012-02-17 Thread Stefan Behnel
The XSLT language is one of the worst misuses of XML, which puts it way > beyond bad. Clearly a matter of opinion. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: generate Windows exe on Linux

2012-02-22 Thread Stefan Behnel
layouting programs from MS-Office fame, but at least older versions of many a program tend to work rather nicely. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: sum() requires number, not simply __add__

2012-02-23 Thread Stefan Behnel
, []) > [1, 2, 3, 4] I know that you just meant this as an example, but it's worth mentioning in this context that it's not exactly efficient to "sum up" lists this way because there is a lot of copying involved. Each adding of two lists creates a third one and copies all elements into it. So it eats a lot of time and space. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python packaging usabilty (distutils) - automatic downloading required packages

2012-02-25 Thread Stefan Behnel
unction, I think. > Do I really switch to setuptools? No, use "distribute" instead. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Fwd: Question about PyXML and python's stdlib xml

2012-02-29 Thread Stefan Behnel
en PyXML? PyXML was meant as an extension and hooked into the stdlib XML support. That's only one of the reasons why it's broken now. > Anyway, python's xml is newer - is PyXML deprecated? Yes. It's a dead project. > Please keep me in CC, I'm not subscribed to the list. That may be the problem in the xml-sig case also. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Porting Python to an embedded system

2012-03-04 Thread Stefan Behnel
t you just install Linux on it? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Porting the 2-3 heap data-structure library from C to Python

2012-03-07 Thread Stefan Behnel
y best to start with Cython right away, instead of using ctypes. http://cython.org/ Here's a tutorial for wrapping a C library with it: http://docs.cython.org/src/tutorial/clibraries.html Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Porting the 2-3 heap data-structure library from C to Python

2012-03-07 Thread Stefan Behnel
g it in a class. > > You should get acquainted with the Python/C API If it proves necessary, yes. > which is the standard way of extending Python with high-performance > (and/or system-specific) C code. Well, it's *one* way. Certainly not the easiest way, neither the most portable and y

Re: cython + scons + c++

2012-03-08 Thread Stefan Behnel
eplace(CYTHONCFILESUFFIX='.cpp') I don't use Scons, so I don't know if running the compiler at a command line level is the best way to do it in that build system. But I know that some people on the Cython users mailing list use it, so you may want to ask over there. https://groups.google.com/group/cython-users Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Porting the 2-3 heap data-structure library from C to Python

2012-03-10 Thread Stefan Behnel
Hrvoje Niksic, 11.03.2012 02:03: > Stefan Behnel writes: >>> which is the standard way of extending Python with high-performance >>> (and/or system-specific) C code. >> >> Well, it's *one* way. Certainly not the easiest way, neither the most >> portab

Re: html5lib not thread safe. Is the Python SAX library thread-safe?

2012-03-12 Thread Stefan Behnel
dated. I'm looking at converting to > html5lib.) You may also consider moving to lxml. BeautifulSoup supports it as a parser backend these days, so you wouldn't even have to rewrite your code to use it. And performance-wise, well ... http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Raise X or Raise X()?

2012-03-12 Thread Stefan Behnel
nce instead. For user provided exceptions, there is no real excuse for raising the type. BTW, StopIteration takes an optional argument in Python 3.3, but that's not a feature that is generally going to be used by Python code, I assume. So I'll just keep raising the type. :) Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Raise X or Raise X()?

2012-03-12 Thread Stefan Behnel
Steven D'Aprano, 12.03.2012 16:08: > On Mon, 12 Mar 2012 14:52:49 +0100, Stefan Behnel wrote: >>> "raise X" is a special case of the 3-args raise. Effectively it just >>> raises an instance of X which is constructed with an empty argument >>> list. Ther

Re: Instantiate a python class object in C

2012-03-14 Thread Stefan Behnel
t; new_demo_obj = my_C_extension.function_2() You should consider giving Cython a try. It will allow you to write normal Python code for your C extension that it translates to efficient C code. This is much easier than writing all of this by hand, especially when it comes to classes. It

Re: Fast file data retrieval?

2012-03-21 Thread Stefan Behnel
rowd, so to me this sounds as overkill Well, there's databases and databases. I agree that the complexity of a SQL database is likely unnecessary here since a key-value database (any of the dbm modules) appears to be sufficient from what the OP wrote. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Compiling Python (modules) on 64bit Windows - which compiler suite?

2012-03-22 Thread Stefan Behnel
head that cygwin induces into a lot of common OS operations (such as fork(), I/O operations or file system access), a native Windows Python installation has serious advantages in most cases. If the choice is GCC, then MinGW is the right tool. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there any difference between print 3 and print '3' in Python ?

2012-03-26 Thread Stefan Behnel
code is produced >> >> Or you could be asking about Python version 3, in which case >> 1) the syntax error message points to a different character > > Oh ,God ! I don't think she takes any responsibility for the list above. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Tools for refactoring/obfuscation

2012-03-27 Thread Stefan Behnel
ode "better" in some way, e.g. by making it more readable or easier to extend. Obfuscation aims for making it worse, as in unreadable and hard to access. It's generally not a good idea to do that. Code is there for humans to read. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Stefan Behnel
, we may be able to tell you how to do what you want. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Stefan Behnel
ere does the data come from and why is it contained in a character string in the first place? If you could provide that information, we can help you further. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: How to resolve circular reference in python C extension?

2012-04-09 Thread Stefan Behnel
ndex; > } It would have been nice if you had added some explanatory text to this code dump. What do you mean by "resolve"? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Gotcha's?

2012-04-09 Thread Stefan Schwarzer
ost likely understand what I'm talking about by reading the code. :-) http://sschwarzer.com/download/robustere_python_programme_clt2010_print.pdf Stefan -- http://mail.python.org/mailman/listinfo/python-list

Naming future objects and their methods

2012-04-14 Thread Stefan Schwarzer
/wiki/Future_%28programming%29 [3] http://www.python.org/dev/peps/pep-3148/ Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Naming future objects and their methods

2012-04-16 Thread Stefan Schwarzer
ut in my reader I only saw one answer in the newsgroup.) Stefan Schwarzer wrote: > I wrote a `Connection` class that can be found at [1]. A > `Connection` object has a method `put_bytes(data)` which > returns a "future" [2]. The data will be sent asynchronously > by a thread

Re: Get stack trace from C

2012-04-16 Thread Stefan Behnel
uot; are and what kind of application we are talking about (graphic, headless server, ...). Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python interface of Stanford Parser

2012-04-20 Thread Stefan Behnel
tial/Stanford_Parser It usually helps to report what exactly you tried and what the result was. Did the installation work at all? How did you install it? What did you try afterwards? What failed? What documentation did you read so far? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Upgrading from 2.7 to 3.x

2012-04-25 Thread Stefan Behnel
t http://python.org Also note that there is a separate mailing list (the tutor list) specifically targeted at new Python users: http://mail.python.org/mailman/listinfo/tutor Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: (3.2) Overload print() using the C API?

2012-04-27 Thread Stefan Behnel
Peter Faulks, 26.04.2012 21:28: > "All you have to do is assign to print". Sounds great! Can some kind soul > hit me with a clue stick? Were do I look in the API? Here's the (Py3) Cython code for it: print = my_print_function Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: (3.2) Overload print() using the C API?

2012-04-27 Thread Stefan Behnel
> > printoverload.set_stdout() > printoverload.set_stderr() > > print("this will be sent to a C function in printoverload.pyd") > --- Why would you want to divert only "print" instead of changing sys.stdout in general? Not all output comes fro

Re: (3.2) Overload print() using the C API?

2012-04-27 Thread Stefan Behnel
Peter Faulks, 27.04.2012 10:36: > On 27/04/2012 5:15 PM, Stefan Behnel wrote: >> Peter Faulks, 26.04.2012 19:57: >>> I want to extend an embedded interpreter so that calls to print() are >>> automagically sent to a C++ gui (windows exe) via a callback function in >&g

Re: (3.2) Overload print() using the C API?

2012-04-28 Thread Stefan Behnel
Peter Faulks, 27.04.2012 22:31: > On 27/04/2012 6:55 PM, Stefan Behnel wrote: >> Peter Faulks, 27.04.2012 10:36: >>> On 27/04/2012 5:15 PM, Stefan Behnel wrote: >>>> Peter Faulks, 26.04.2012 19:57: >>>>> I want to extend an embedded interpreter so that

Re: "

2012-05-04 Thread Stefan Behnel
Ian Kelly, 04.05.2012 01:02: > BeautifulSoup is supposed to parse like a browser would Not at all, that would be html5lib. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python Lazy?

2012-05-05 Thread Stefan Behnel
if you really wanted to do this particular thing, I'd just use heapq. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: sorting 1172026 entries

2012-05-06 Thread Stefan Behnel
, 'wb') as p: >> for i, j in temp: >>p.write('%s %s\n' %(str(i),j)) How much memory do you have on your system? Does the list fit into memory easily or is it swapping to disk while you are running the sort? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Retrieving result from embedded execution

2012-05-10 Thread Stefan Behnel
f HTML mails. Your problem description was very good, BTW. It included the perfect amount of information about what you tried and what didn't work for you about it. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
ten faster than hand written C code). http://cython.org/ Here are a couple of examples: http://docs.cython.org/src/tutorial/external.html There's also the "ctypes" package in the standard library, which is usable for simple wrapping cases that are not performance critical.

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
O is much better spent adding features and tuning the code for performance. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
Mark Lawrence, 13.05.2012 19:27: > On 13/05/2012 16:58, Stefan Behnel wrote: >> David Shi, 13.05.2012 15:25: >>> Can anyone tell me how to call and exectute C code in Python? >> >> Take a look at Cython, a Python-like language that supports native calls to >>

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
Mark Lawrence, 13.05.2012 19:44: > On 13/05/2012 18:38, Stefan Behnel wrote: >> Mark Lawrence, 13.05.2012 19:23: >>> On 13/05/2012 16:39, Chris Angelico wrote: >>>> On Sun, May 13, 2012 at 11:25 PM, David Shi wrote: >>>>> Can anyone tell

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
re discussing at *that* level. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
them, and they got it pretty much right (didn't try the others). Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Need to get Tags and Values from Dom

2012-05-13 Thread Stefan Behnel
as ET # using fast C accelerator module root = ET.parse("afile.xml").getroot() for child in root: if child.tag == 'abc': print("abc tag found") else: print("other tag found") There's also an incremental i

Re: Need to get Tags and Values from Dom

2012-05-14 Thread Stefan Behnel
en you can just get your code working without having to learn all of this again? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: ucs2 and ucs4 python

2012-05-16 Thread Stefan Behnel
> install them all again somehow... You should install "distribute" and "pip" into it, then you can use pip to install packages directly and automatically from the Python Package Index (PyPI), including any dependencies. Even better, use "virtualenv" to create a local

Re: python and xml

2012-05-16 Thread Stefan Behnel
s some untested code to print the text values: import xml.etree.ElementTree as ET loadavg = ET.fromstring('0.000.00' '0.00') for interval_tag in ('one', 'five', 'fifteen'): print(loadavg.findtext(interval_tag)) Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: python and xml

2012-05-16 Thread Stefan Behnel
Hi, please don't top-post (I fixed the citation order below). Nibin V M, 16.05.2012 16:30: > On Wed, May 16, 2012 at 7:53 PM, Stefan Behnel wrote: >> Nibin V M, 16.05.2012 16:16: >>> I am trying to use cPanel XML-API and every API call return data in XML >>> for

Re: Where is the latest step by step guide to use Jython to compile Python into Java?

2012-06-04 Thread Stefan Behnel
usually helps to provide a pointer to that "not updated text", so that readers know what you are talking about and can more easily provide an alternative. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Where is the latest step by step guide to use Jython to compile Python into Java?

2012-06-04 Thread Stefan Behnel
ollect all Java code that Jython executes during the run of a Python program, you get pure Java code that is equivalent to the Python program. Maybe not beautiful code, but definitely Java code. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Where is the latest step by step guide to use Jython to compilePython into Java?

2012-06-04 Thread Stefan Behnel
David Shi, 04.06.2012 17:35: > Compiling your Python code with jythonc > I do not know whether I downloaded a wrong version of Jythonc? Or, got > mismatched software or instructions. Jythonc used to work in Jython 2.2 but is no longer supported in Jyton 2.5. Stefan -- http://mail.p

Re: validating XML

2012-06-13 Thread Stefan Behnel
andrea crotti, 13.06.2012 12:06: > Hello Python friends, I have to validate some xml files against some xsd > schema files, but I can't use any cool library as libxml unfortunately. Any reason for that? Because the canonical answer to your question would be lxml, which uses libxm

Re: Academic citation of Python

2012-06-17 Thread Stefan Behnel
rt of translate to "of the" and for a book spine "of the XYZ" > may be meaningless unless the given name is included, a la "ABC of the > XYZ"... It's a bit like using "New York" as a surname, when you refer to that guy Jason who was born there, as in "Jason of New York". Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Nimp: Nested Imports (a la Java)

2011-06-16 Thread Stefan Behnel
though - which ones should be executed if the package structure is multiplied? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: NEED HELP-process words in a text file

2011-06-19 Thread Stefan Behnel
Add two numbers. >>> 1+1 2 >>> add(1,1) 2 >>> add(1,1) == 1+1 True """ return x+y http://docs.python.org/library/doctest.html Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: keeping local state in an C extension module

2011-06-30 Thread Stefan Behnel
Or is this approach a stupid idea to begin with? Pointers would be highly appreciated. Spot the pun. ;) Take a look at PyCapsule, it may (or may not) be enough for your use case. However, note the comment about Py_InitModule4() in the docs, where it says that the 'self' passing fe

<    1   2   3   4   5   6   7   8   9   10   >