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: (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: (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-27 Thread Stefan Behnel
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 > the DLL. > > Then I'll be able to do this: > > test.py > import printoverload > > printoverload.set_stdout(

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: Upgrading from 2.7 to 3.x

2012-04-25 Thread Stefan Behnel
deuteros, 26.04.2012 05:08: > I'm fairly new to Python I have version 2.7 installed on my computer. However > my professor wants us all to use the latest version of Python. Did he/she explicitly tell you to install Python 3? 2.7 is the latest version of Python 2.x, some people may mix that up. O

Re: Python interface of Stanford Parser

2012-04-20 Thread Stefan Behnel
ac27037, 20.04.2012 15:19: > Does anybody know how to use the Stanford Parser for Python Interface? I have > tried many times, and don't know how to install and use. In fact, I have > failed at that many times. Here is the interface: > > http://projects.csail.mit.edu/spatial/Stanford_Parser It

Re: Get stack trace from C

2012-04-16 Thread Stefan Behnel
Eric Frederich, 16.04.2012 20:14: > I embed Python in a 3rd party application. > I need to use their conventions for errors. > > Looking here... > http://docs.python.org/extending/embedding.html#pure-embedding > the example uses PyErr_Print() but that goes to stdout or stderr or > somethin

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

2012-04-09 Thread Stefan Behnel
罗勇刚(Yonggang Luo) , 09.04.2012 04:28: > static PyObject * > Repository_get_index(Repository *self, void *closure) > { > int err; > git_index *index; > Index *py_index; > > assert(self->repo); > > if (self->index == NULL) { > err = git_repository_index(&index, self->rep

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

2012-03-28 Thread Stefan Behnel
Peter Daum, 28.03.2012 11:43: > What I am looking for is a general way to just copy the raw data > from a "string" object to a "byte" object without any attempt to > "decode" or "encode" anything ... That's why I asked about your use case - where does the data come from and why is it contained in

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

2012-03-28 Thread Stefan Behnel
Peter Daum, 28.03.2012 10:56: > is there any way to convert a string to bytes without > interpreting the data in any way? Something like: > > s='abcde' > b=bytes(s, "unchanged") If you can tell us what you actually want to achieve, i.e. why you want to do this, we may be able to tell you how to d

Re: Tools for refactoring/obfuscation

2012-03-27 Thread Stefan Behnel
Javier, 07.03.2012 04:29: > I am looking for an automated tool for refactoring/obfuscation. Sadly, there really is one thing that these two have in common: they modify code while retaining its exact functionality. Apart from that, they are diametric opposites. Refactoring aims at making the code "

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

2012-03-26 Thread Stefan Behnel
redstone-c...@163.com, 26.03.2012 16:28: > 在 2012年3月26日星期一UTC+8下午8时11分03秒,Dave Angel写道: >> On 03/26/2012 07:45 AM, redstone-c...@163.com wrote: >>> I know the print statement produces the same result when both of these two >>> instructions are executed ,I just want to know Is there any difference

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

2012-03-22 Thread Stefan Behnel
Thomas Bach, 21.03.2012 20:03: > Ralph Heinkel writes: >> when processing our mass spectrometry data we are running against the >> 2GB memory limit on our 32 bit machines. So we are planning to move to >> 64bit. Downloading and installing the 64bit version of Python for >> Windows is trivial, but h

Re: Fast file data retrieval?

2012-03-21 Thread Stefan Behnel
Jorgen Grahn, 13.03.2012 21:44: > On Mon, 2012-03-12, MRAB wrote: >> Probably the best solution is to put it into a database. Have a look at >> the sqlite3 module. > > Some people like to use databases for everything, others never use > them. I'm in the latter crowd, so to me this sounds as overki

Re: Instantiate a python class object in C

2012-03-14 Thread Stefan Behnel
Dids, 14.03.2012 14:46: > Apologies if this was asked before, I couldn't find anything. > > I have a class defined in a python file: > for example: > > class demo: > [ class definition goes here] > > I'm writing a C extension. > In the first function, I take an instance of the "demo" class

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: Raise X or Raise X()?

2012-03-12 Thread Stefan Behnel
Irmen de Jong, 11.03.2012 21:37: > On 11-3-2012 20:04, bvdp wrote: >> Which is preferred in a raise: X or X()? I've seen both. In my specific case >> I'm dumping out of a deep loop: >> >> try: >> for ... >> for ... >> for ... >> if match: >>raise StopInteration() >>

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

2012-03-12 Thread Stefan Behnel
John Nagle, 11.03.2012 21:30: >"html5lib" is apparently not thread safe. > (see "http://code.google.com/p/html5lib/issues/detail?id=189";) > Looking at the code, I've only found about three problems. > They're all the usual "cached in a global without locking" bug. > A few locks would fix that.

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: cython + scons + c++

2012-03-08 Thread Stefan Behnel
Neal Becker, 08.03.2012 15:23: > Is there a version of cython.py, pyext.py that will work with c++? > > I asked this question some time ago, but never got an answer. > > I tried the following code, but it doesn't work correctly. If the commented > lines are uncommented, the gcc command is total

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

2012-03-07 Thread Stefan Behnel
Hrvoje Niksic, 07.03.2012 16:48: > Alec Taylor writes: > >> The source-code used has been made available: >> http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.h >> http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.c >> >> I plan on wrapping it in a class. > > You should get acquainted

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

2012-03-07 Thread Stefan Behnel
Alec Taylor, 07.03.2012 15:25: > I am planning to port the 2-3 heap data-structure as described by > Professor Tadao Takaoka in Theory of 2-3 Heaps published in 1999 and > available in PDF: > http://www.cosc.canterbury.ac.nz/tad.takaoka/2-3heaps.pdf > > The source-code used has been made available

Re: Porting Python to an embedded system

2012-03-04 Thread Stefan Behnel
Justin Drake, 04.03.2012 11:58: > I am working with an ARM Cortex M3 on which I need to port Python > (without operating system). What would be my best approach? I just > need the core Python and basic I/O. The "without operating system" bit should prove problematic. Can't you just install Linux o

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

2012-02-29 Thread Stefan Behnel
Roman Rakus, 29.02.2012 15:33: > I'm forwarding this message to python-list, since I didn't get answer on > xml-sig ML I didn't see a message from you on that list. > I have concerns about PyXML and stdlib xml included directly in python. > Currently (in Fedora) python is trying to import PyXML,

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

2012-02-25 Thread Stefan Behnel
XLiIV, 25.02.2012 15:47: > There is many packaging solutions for python. > I was confused about that but it's nothing. I had to pick one of them. > I picked distutils because it's part of standard python since 3.3, am > i right? Distutils has been part of Python's stdlib for ages. > My goal is t

Re: sum() requires number, not simply __add__

2012-02-23 Thread Stefan Behnel
Chris Rebert, 23.02.2012 22:32: > On Thu, Feb 23, 2012 at 1:19 PM, Buck Golemon wrote: >> I feel like the design of sum() is inconsistent with other language >> features of python. Often python doesn't require a specific type, only >> that the type implement certain methods. >> >> Given a class th

Re: generate Windows exe on Linux

2012-02-22 Thread Stefan Behnel
Gelonida N, 22.02.2012 23:25: > On 02/22/2012 07:05 PM, Alec Taylor wrote: >> http://www.pyinstaller.org/ >> >> or >> >> http://cx-freeze.sourceforge.net/ >> >> You can also run py2exe in WINE >> > > You want to say, that I could install python 2.6 > some packages like win32api > PyQt and tand py2

Re: XSLT to Python script conversion?

2012-02-17 Thread Stefan Behnel
Ross Ridge, 17.02.2012 21:37: > Matej Cepl wrote: >> No, the strangness is not that bad (well, it is bad ... almost anything >> feels bad comparing to Python, to be honest, but not the reason I would >> give up; after all I spent couple of years with Javascript). > > The XSLT language is one of

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. Stefan -- http://mail.pyt

Re: Complexity question on Python 3 lists

2012-02-15 Thread Stefan Behnel
Ian Kelly, 15.02.2012 19:43: > On Wed, Feb 15, 2012 at 11:20 AM, Franck Ditter wrote: >> Do lists in Python 3 behave like ArrayList in Java (if the capacity >> is full, then the array grows by more than 1 element) ? > > I believe the behavior in CPython is that if the array is full, the > capacity

Re: XSLT to Python script conversion?

2012-02-13 Thread Stefan Behnel
Matej Cepl, 13.02.2012 12:20: > I am getting more and more discouraged from using XSLT for a transformation > from one XML scheme to another one. Could you explain what it is that discourages you about it? That would allow us to come up with better alternatives for your specific problem. > Does

Re: Python usage numbers

2012-02-11 Thread Stefan Behnel
Eric Snow, 11.02.2012 22:02: > - categories (web, scripts, "big data", computation, etc.) No numbers, but from my stance, the four largest areas where Python is used appear to be (in increasing line length order): a) web applications b) scripting and tooling c) high-performance computation d) tes

Re: Fabric Engine + Python benchmarks

2012-02-10 Thread Stefan Behnel
Fabric Paul, 10.02.2012 17:04: > Fabric is a high-performance multi-threading engine that > integrates with dynamic languages. Hmm, first of all, fabric is a tool for automating admin/deployment/whatever tasks: http://pypi.python.org/pypi/Fabric/1.3.4 http://docs.fabfile.org/en/1.3.4/index.html

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.

Re: Iterate from 2nd element of a huge list

2012-02-01 Thread Stefan Behnel
Paul Rubin, 01.02.2012 10:25: > Paulo da Silva writes: >> process1(mylist[0]) >> for el in mylist[1:]: >> process2(el) >> >> This way mylist is almost duplicated, isn't it? > > I think it's cleanest to use itertools.islice to get the big sublist > (not tested): > >from itertools import i

Re: xhtml encoding question

2012-02-01 Thread Stefan Behnel
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. > Also, I have to replace certain characters with html entities. > > I think I've got this right, but I'd like to hear if there

Re: PyPI - how do you pronounce it?

2012-01-28 Thread Stefan Behnel
Chris Angelico, 28.01.2012 08:48: > Hopefully this will be a step up from Rick's threads in usefulness, > but I'm aware it's not of particularly great value! > > How do you pronounce PyPI? Is it: > * Pie-Pie? I consider this taken by PyPy, and I tend to run into the trap of pronouncing both the s

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

2012-01-26 Thread Stefan Behnel
umedoblock, 27.01.2012 03:03: > I'd like to call super() in c extension. > I'd like to rewrite class Baa as c extension. Have you considered using Cython for this? It will allow you to do exactly that with only minor changes to your Python code (if any). And it's quite likely that the C code that

Re: Libxml2 Python Manual

2012-01-24 Thread Stefan Behnel
Mauricio Martinez Garcia, 25.01.2012 02:46: > For libxml2, are there any manual. For this library?, i searched on > google and just find the following URL xmlsoft.org > Wich can not find any API manual. I will apreciate your support if have one > for the library in python. Any reason you're not

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

2012-01-24 Thread Stefan Behnel
Chris Angelico, 24.01.2012 05:47: > Lua and Pike both quite happily solved hash collision attacks in their > interning of strings by randomizing the hash used, because there's no > way to rely on it. Presumably (based on the intern() docs) Python can > do the same, if you explicitly intern your str

Re: lxml to parse html

2012-01-23 Thread Stefan Behnel
contro opinion, 23.01.2012 08:34: > import lxml.html > myxml=''' > > > > > table="tpa_radio_sum"> > > > > > > > ''' > root=lxml.html.fromstring(myxml) > nodes1=root.xpath('//job[@DecreaseHour="1"]') > nodes2=

Re: etree/lxml/XSLT and dynamic stylesheet variables

2012-01-20 Thread Stefan Behnel
Adam Tauno Williams, 20.01.2012 21:38: > I'm using etree to perform XSLT transforms, such as - > > from lxml import etree > source = etree.parse(self.rfile) > xslt = etree.fromstring(self._xslt) > transform = etree.XSLT(xslt) > result = transform(source) > > according to the docs at >

Re: C++ and Embedded Python

2012-01-20 Thread Stefan Behnel
jasonked...@hotmail.com, 20.01.2012 14:52: > Is there a method to allow a pointer to an object in local memory to > be shared with embedded Python within a C++ executable? > > The reason I require this is I have a C++ instance of a class that has > data memers that are themeselves pointers to othe

Re: Hash stability

2012-01-15 Thread Stefan Behnel
Chris Angelico, 15.01.2012 17:13: > Of course, it's still dodgy to depend on the stability of something > that isn't proclaimed stable, and would be far better to use some > other hashing algorithm (MD5 or SHA for uberreliability). I've seen things like MD5 or SHA* being used quite commonly for fi

Re: Extension module question

2012-01-15 Thread Stefan Behnel
Evan Driscoll, 15.01.2012 08:37: > As I hinted at in an earlier email, I'm working on a module which will > allow calling readdir() (and FindFirstFile on Windows, hopefully pretty > uniformly) from Python. The responses I got convinced me that it was a > good idea to write a C-to-Python bridge as a

Re: defining class and subclass in C

2012-01-15 Thread Stefan Behnel
Daniel Franke, 14.01.2012 22:15: > I spent some days and nights on this already and my google-fu is running out. > I'd like to implement the equivalent of this Python code in a C-extension: > > >>> class A(object): > pass > >>> class B(A): > pass > >>> A > > >>> B > > >>> B.__bases__

Re: Hash stability

2012-01-15 Thread Stefan Behnel
Heiko Wundram, 14.01.2012 23:45: > Am 14.01.2012 10:46, schrieb Peter Otten: >> Steven D'Aprano wrote: >>> How many people rely on hash(some_string) being stable across Python >>> versions? Does anyone have code that will be broken if the string hashing >>> algorithm changes? >> >> Nobody who under

Re: open office in another language?

2012-01-13 Thread Stefan Behnel
Wolfgang Keller, 13.01.2012 17:22: >> I'm a somewhat-satisfied openoffice.org user. I mean it works, but if >> it weren't in Java I'd be doing some of my own tweaking. But since >> it's in Java I stay away... no likey. > > OpenOffice (now LibreOffice, btw.) is not implemented in Java, if that's >

Re: Zealotry [was Re: how to install lxml in window xp?] (OT)

2012-01-13 Thread Stefan Behnel
Noah Hall, 13.01.2012 08:29: > I'M SO COOL > USE MY HARDCORE GENTOO INSTALL THAT TOOK 36 HOURS AND SHAVED 2 SECONDS > OFF MY BOOTUP TIME Just an off-topic thing that your comment above reminded me of: has anyone ever noticed that there are even quick install guides for Gentoo Linux? I think that'

Re: Zealotry [was Re: how to install lxml in window xp?]

2012-01-12 Thread Stefan Behnel
alex23, 13.01.2012 06:41: > On Jan 13, 3:02 pm, Steven D'Aprano wrote: >> Why is it that only Linux and Mac users are accused of being "zealots"? > > Oh please. Don't tar me with the Windows brush. I'd have used the same > term no matter what OS was being recommended. > >> If I ask how to install

Re: Is there a way to merge two XML files via Python?

2012-01-12 Thread Stefan Behnel
J, 12.01.2012 17:04: > This is more a theory exercise and something I'm trying to figure out, > and this is NOT a homework assignment... > > I'm trying to make a tool I use at work more efficient :) > > So this is at test tool that generates an XML file as it's output that > is eventually used by

Re: open office in another language?

2012-01-11 Thread Stefan Behnel
Paul Rudin, 11.01.2012 11:17: > Stefan Behnel writes: >> OOo has been fully scriptable in Python for ages. It even comes with an >> embedded Python runtime for that purpose [...] > > I have dabbled with PyUNO in the past. One issue is that the api seems > rather unp

Re: open office in another language?

2012-01-11 Thread Stefan Behnel
Sean Wolfe, 10.01.2012 22:43: > I'm a somewhat-satisfied openoffice.org user. I mean it works, but if > it weren't in Java I'd be doing some of my own tweaking. But since > it's in Java I stay away... no likey. It's been in C++ ever since the old StarOffice days, others have commented on that alre

Re: C-API: Pass a tuple to a method of a class

2012-01-10 Thread Stefan Behnel
[cleaned up top-posted citation order to make the replies readable] 刘振海, 10.01.2012 14:24: > 2012/1/10 Stefan Behnel >> """ >> # in module "gluecode.pyx" (or whatever you want to name it) >> >> import mModule8 >> >> cdef ap

Re: C-API: Pass a tuple to a method of a class

2012-01-10 Thread Stefan Behnel
Hi again, just as a little teaser, to make it clear that I'm not joking, here's your code below translated into Cython. Stefan Behnel, 10.01.2012 13:33: > paspa...@noos.fr, 10.01.2012 11:57: >> the code is the following: > [...] >> // Class >> pclass = PyOb

Re: C-API: Pass a tuple to a method of a class

2012-01-10 Thread Stefan Behnel
Hi! paspa...@noos.fr, 10.01.2012 11:57: > I am trying to pass a tuple to a method of a class from C++ to Python. I get > a > Run Failed from the execution. > thanks for help/suggestions My *suggestion* is to use Cython instead of writing the glue code yourself. There are several bugs and lots o

Re: how to install lxml in window xp?

2012-01-09 Thread Stefan Behnel
水静流深, 09.01.2012 10:18: > in my xp ,python26,easy_install installed. > i want to install lxml in window xp > 1.c:\python26\scripts\easy_install lxml > > what i get is: > > Reading http://codespeak.net/lxml > Best match: lxml 2.3.3 > Downloading http://lxml.de/files/lxml-2.3.3.tgz > Processi

Re: Getting involved - Jython ElementTree performance

2012-01-07 Thread Stefan Behnel
Sophie Sperner, 07.01.2012 13:01: > On Jan 7, 11:53 am, Stefan Behnel wrote: >> A big issue that I have with Jython is that its ElementTree XML parser >> support is so increadibly slow. It could seriously benefit from a better >> integration between the Java XML support i

Re: Getting involved

2012-01-07 Thread Stefan Behnel
Andrew Berg, 07.01.2012 12:16: > On 1/7/2012 4:59 AM, Sophie Sperner wrote: >> Could you please list me 2 or 3 projects in Python and/or Java which >> are currently active (vivid) and useful? > > If you really want to mix Python and Java, you could help the Jython > project [...] A big issue that

Re: Anyone still using Python 2.5?

2011-12-21 Thread Stefan Behnel
Dennis Lee Bieber, 21.12.2011 17:48: On Wed, 21 Dec 2011 07:15:46 +, Chris Withers wrote: What's the general consensus on supporting Python 2.5 nowadays? Do people still have to use this in commercial environments or is everyone on 2.6+ nowadays? I was recently laid-off from a program tha

Re: Anyone still using Python 2.5?

2011-12-21 Thread Stefan Behnel
Chris Withers, 21.12.2011 08:15: What's the general consensus on supporting Python 2.5 nowadays? From my own (recent) polls, it appears that people want continued support for Python 2.4 and later for a couple of years to come, mainly because RHEL5 uses that by default and has official support

Re: Python education survey

2011-12-20 Thread Stefan Behnel
Devin Jeanpierre, 20.12.2011 08:32: Truthfully I'm not sure why it's great for teaching, though. And there were some discussions I overheard about perhaps switching to PyCharm, which at least one professor thought was much better. I recently started using PyCharm personally, but not for my cour

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Stefan Behnel
Nathan Rice, 16.12.2011 19:51: Nothing stops me from implementing it, in fact it is VERY trivial to wrap member class methods onto a list subclass, and wrap functions to support vectorized behavior. The problem is that as soon as you hit anything outside your code that returns a list or iterator

Re: Making the case for "typed" lists/iterators in python

2011-12-16 Thread Stefan Behnel
Nathan Rice, 16.12.2011 18:48: I realize this has been discussed in the past, I hope that I am presenting a slightly different take on the subject that will prove interesting. This is primarily motivated by my annoyance with using comprehensions in certain circumstances. Currently, if you want

Re: test for list equality

2011-12-15 Thread Stefan Behnel
noydb, 15.12.2011 18:49: On Dec 15, 11:36 am, noydb wrote: I want to test for equality between two lists. For example, if I have two lists that are equal in content but not in order, I want a return of 'equal' -- dont care if they are not in the same order. In order to get that equality, would

Re: xml, minidom, ElementTree

2011-12-13 Thread Stefan Behnel
Terry Reedy, 14.12.2011 06:01: On 12/13/2011 6:21 PM, Ethan Furman wrote: In the near future I will need to parse and rewrite parts of a xml files created by a third-party program (PrintShopMail, for the curious). It contains both binary and textual data. There has been some strong debate about

Re: Fixing the XML batteries

2011-12-13 Thread Stefan Behnel
ru...@yahoo.com, 13.12.2011 20:37: On Dec 13, 5:32 am, Stefan Behnel wrote: In Python 2.7/3.2, ElementTree has support for C14N serialisation, just pass the option method="c14n". Where does one find information in the Python documentation about this? Hmm, interesting. I though i

Re: Fixing the XML batteries

2011-12-13 Thread Stefan Behnel
Serhiy Storchaka, 13.12.2011 19:57: 13.12.11 16:59, Stefan Behnel написав(ла): It matches my opinion though. I would be glad to divide your intentions, however ElementTree looks less documented than minidom It's certainly a lot smaller, which makes its API easier to learn and rem

Re: Fixing the XML batteries

2011-12-13 Thread Stefan Behnel
Serhiy Storchaka, 13.12.2011 15:27: 13.12.11 14:32, Stefan Behnel написав(ла): I stripped my name from the quoted context because I didn't say this. I am glad to hear this. ;) It matches my opinion though. I use xml.dom.minidom for XML canonization and convertion: Do you

Re: Fixing the XML batteries

2011-12-13 Thread Stefan Behnel
Serhiy Storchaka, 13.12.2011 13:17: 09.12.11 17:09, Dirkjan Ochtman wrote: An at least somewhat informed +1 from me. The ElementTree API is a very good way to deal with XML from Python, and it deserves to be promoted over the included alternatives. Let's deprecate the NiCad batteries and try to

Re: Django ported to Python3!

2011-12-02 Thread Stefan Behnel
Ron, 02.12.2011 22:47: It looks like Vinay Sajip has succeeded in porting Django to Python3 (in a shared code base for Python 3.2 and Python 2.7). This is an astoundingly good job, done very fast and is big news. See https://groups.google.com/forum/#!topic/django-developers/XjrX3FIPT-U and the ac

Re: Python 3 - xml - crlf handling problem

2011-12-02 Thread Stefan Behnel
durumdara, 02.12.2011 09:13: So: may I don't understand the things well, but I thought that parser drop the "nondata" CRLF-s + other characters (not preserve them). Well, it does that, at least on my side (which is not under Windows): === original=''' AnyText

Re: Python 3 - xml - crlf handling problem

2011-11-30 Thread Stefan Behnel
durumdara, 30.11.2011 13:08: As I see that XML parsing is "wrong" in Python. You didn't say what you are using for parsing, but from your example, it appears likely that you are using the xml.dom.minidom module. I must use predefined XML files, parsing them, extending them, and produce som

Re: suppressing bad characters in output PCDATA (converting JSON to XML)

2011-11-29 Thread Stefan Behnel
Adam Funk, 29.11.2011 13:57: On 2011-11-28, Stefan Behnel wrote: Adam Funk, 25.11.2011 14:50: Then I recurse through the contents of big_json to build an instance of xml.dom.minidom.Document (the recursion includes some code to rewrite dict keys as valid element names if necessary) If the

Re: Executing .pyc using python c api

2011-11-29 Thread Stefan Behnel
Mrinalini Kulkarni, 29.11.2011 08:34: I need to run .pyc files using python c api. if i do PyImport_Import it executes the script. However, i need to pass a set of variables and their values which will be accessed from within the script. How can this be done. Assuming you have the source as wel

Re: suppressing bad characters in output PCDATA (converting JSON to XML)

2011-11-28 Thread Stefan Behnel
Adam Funk, 25.11.2011 14:50: I'm converting JSON data to XML using the standard library's json and xml.dom.minidom modules. I get the input this way: input_source = codecs.open(input_file, 'rb', encoding='UTF-8', errors='replace') It doesn't make sense to use codecs.open() with a "b" mode.

Re: lxml precaching DTD for document verification.

2011-11-27 Thread Stefan Behnel
Gelonida N, 27.11.2011 18:57: I'd like to verify some (x)html / / html5 / xml documents from a server. These documents have a very limited number of different doc types / DTDs. So what I would like to do is to build a small DTD cache and some code, that would avoid searching the DTDs over and o

Re: suitability of python

2011-11-27 Thread Stefan Behnel
Rudra Banerjee, 24.11.2011 12:31: I am a newbie in python and basically i use python for postprocessing like plotting, data manipulation etc. Based on ease of programming on python I am wondering if I can consider it for the main development as well. My jobs (written on fortran) runs for weeks an

Re: Writing code to be optimizable

2011-11-22 Thread Stefan Behnel
snorble, 23.11.2011 06:19: Sometimes I want to prototype a program in Python, with the idea of optimizing it later by rewriting parts of it in C or Cython. But I usually find that in order to rewrite the slow parts, I end up writing those parts very much like C or C++ anyway, and I end up wonderi

Re: xml.dom.minidom question

2011-11-20 Thread Stefan Behnel
nivashno, 19.11.2011 22:32: I've got this code: >>> dom = xml.dom.minidom.parse('myfile.xml') >>> for testnode in dom.getElementsByTagName('tests')[0].childNodes: ... print testnode When it's working on this xml: something I get the following: But when it's working

Re: RSS feed creation?

2011-11-07 Thread Stefan Behnel
Stefan Behnel, 07.11.2011 08:22: Dan Stromberg, 06.11.2011 21:00: Is there an opensource Python tool for creating RSS feeds, that doesn't require large dependencies? I found feedformatter.py on pypi, but it seems a little old, and its sole automated test gives a traceback. Is there a b

Re: RSS feed creation?

2011-11-06 Thread Stefan Behnel
Dan Stromberg, 06.11.2011 21:00: Is there an opensource Python tool for creating RSS feeds, that doesn't require large dependencies? I found feedformatter.py on pypi, but it seems a little old, and its sole automated test gives a traceback. Is there a better starting point? (I'd of course pref

Re: Database access benchmarks for use in web-frameworks - How does Python compare?

2011-11-04 Thread Stefan Behnel
Alec Taylor, 03.11.2011 11:19: I'm building a large e-commerce site, and it is very important that what I write can: - Handle larger server load - Deliver pages quickly - Make transactions quickly Those are pretty broad requirements. If a framework can satisfy them or not depends more on how y

Re: Full time Job opening -Python lead in washington area.

2011-11-03 Thread Stefan Behnel
Radhika Bauerle, 03.11.2011 01:05: Hello eveyone: Well, and here's the problem already: "everyone". Note that it's commonly considered inappropriate to post job offers on this list. Please use the Python job board instead: http://python.org/community/jobs/ (easy to find by clicking on "pyt

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-11-01 Thread Stefan Behnel
pyt...@bdurham.com, 31.10.2011 20:54: Wondering if there's a fast/efficient built-in way to determine if a string has non-ASCII chars outside the range ASCII 32-127, CR, LF, or Tab? I know I can look at the chars of a string individually and compare them against a set of legal chars using standa

Re: C API: Making a context manager

2011-11-01 Thread Stefan Behnel
Chris Kaynor, 01.11.2011 17:19: On Tue, Nov 1, 2011 at 8:57 AM, Stefan Behnel wrote: Chris Kaynor, 31.10.2011 19:34: I am currently rewritting a class using the Python C API to improve performance of it, however I have not been able to find any documentation about how to make a context manager

Re: C API: Making a context manager

2011-11-01 Thread Stefan Behnel
Chris Kaynor, 31.10.2011 19:34: I am currently rewritting a class using the Python C API to improve performance of it, however I have not been able to find any documentation about how to make a context manager using the C API. You should take a look at Cython. It makes these things *so* much ea

Re: Exception Handling (C - extending python)

2011-10-25 Thread Stefan Behnel
Ulrich Eckhardt, 25.10.2011 08:49: Am 23.10.2011 14:41, schrieb Stefan Behnel: That's just fine. If you are interested in the inner mechanics of the CPython runtime, reading the source is a very good way to start getting involved with the project. However, many extension module authors

Re: 回复: install lxml

2011-10-24 Thread Stefan Behnel
水静流深, 24.10.2011 07:31: The latest version is lxml 2.3.1, released 2011-09-25, 1.download it 2.extract it ,put it in the /home/user/Python-3.2.2/libxml2-2.7.8 3.cd /home/user/Python-3.2.2/libxml2-2.7.8 4. ./configure 5.make 6.sudo make install Not libxml2. lxml. when i finished ~$

Re: Exception Handling (C - extending python)

2011-10-23 Thread Stefan Behnel
Hi, note that I reformatted your posting to get the replies back into order. Lee, 23.10.2011 13:32: On Oct 23, 10:06 pm, Stefan Behnel wrote: Lee, 23.10.2011 06:09: Where does PyExc_TypeError (and alike) points to? I can see its declaration - PyAPI_DATA(PyObject *) PyExc_TypeError; - in

Re: Exception Handling (C - extending python)

2011-10-23 Thread Stefan Behnel
Lee, 23.10.2011 06:09: Where does PyExc_TypeError (and alike) points to? I can see its declaration - PyAPI_DATA(PyObject *) PyExc_TypeError; - in pyerrors.h but I cannot figure out what it is its value, where it is initialized. It gets initialised inside of the interpreter core and then points

Re: Benefits of xml.dom.minidom?

2011-10-20 Thread Stefan Behnel
John Gordon, 20.10.2011 19:46: I recently inherited some code that uses xml.dom.minidom to build a large XML document, and I noticed that it is quite slow and uses a ton of memory. I converted the same code to use lxml.etree and it is much faster and uses not nearly so much memory. Why is minid

Re: Are range iterators thread safe?

2011-10-20 Thread Stefan Behnel
Ben Finney, 20.10.2011 13:23: Stefan Behnel writes: Steven D'Aprano, 20.10.2011 10:04: Using Python 3, are range_iterator objects thread-safe? The GIL ensures it's thread safe. The GIL applies only to CPython. and PyPy. What is the answer for other Python implementations w

Re: Are range iterators thread safe?

2011-10-20 Thread Stefan Behnel
Steven D'Aprano, 20.10.2011 10:04: Using Python 3, are range_iterator objects thread-safe? I have tried this, and it seems to be safe: >>> from threading import Thread >>> x = iter(range(4)) >>> def doit(x): ... print("result =", next(x)) ... >>> threads = [Thread(target=doit, args=(x,)) fo

Re: Language Enhancement Idea to help with multi-processing (your opinions please)

2011-10-13 Thread Stefan Behnel
Martin P. Hellwig, 13.10.2011 14:35: I was wondering if there could be an advantage to add another control flow statement. Changes at that level must be very well justified, are often rejected for the reason of being not too complicated to write in some other form and are close to impossible

Re: parse html:what is the meaning of "//"?

2011-09-16 Thread Stefan Behnel
alias, 16.09.2011 08:39: code1: import lxml.html import urllib down='http://finance.yahoo.com/q/op?s=C+Options' content=urllib.urlopen(down).read() root=lxml.html.document_fromstring(content) I see this quite often, but many people don't know that this can be simplified to import lxml.ht

stackoverflow and c.l.py (was: GIL switch interval)

2011-09-13 Thread Stefan Behnel
Matt Joiner, 14.09.2011 04:23: i'm curious as to what can be done with (and handled better) by adjusting sys.setswitchinterval i've opened a question on SO for this, that people might find of interest: http://stackoverflow.com[...] I wonder why people ask this kind of question on stackoverflow,

Re: working with a large file

2011-09-12 Thread Stefan Behnel
Rita, 12.09.2011 12:34: I have a large file, 18gb uncompressed, and I would like to know what is the preferred method to read this file for random access. I have several processes reading the file which different calculate arguments. My server has 64gb of memory. Not sure what is the preferred wa

Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-12 Thread Stefan Behnel
Alec Taylor, 12.09.2011 10:33: from creole import html2creole from BeautifulSoup import BeautifulSoup VALID_TAGS = ['strong', 'em', 'p', 'ul', 'li', 'br', 'b', 'i', 'a', 'h1', 'h2'] def sanitize_html(value): soup = BeautifulSoup(value) for tag in soup.findAll(True): if tag.na

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