Re: intolerant HTML parser

2010-02-08 Thread Stefan Behnel
Lawrence D'Oliveiro, 08.02.2010 11:19: > In message <4b6fd672$0$6734$9b4e6...@newsspool2.arcor-online.net>, Stefan > Behnel wrote: > >> Jim, 06.02.2010 20:09: >> >>> I generate some HTML and I want to include in my unit tests a check >>> fo

Re: use strings to call functions

2010-02-08 Thread Stefan Behnel
Klaus Neuner, 08.02.2010 11:57: > I am writing a program that analyzes files of different formats. I > would like to use a function for each format. Obviously, functions can > be mapped to file formats. E.g. like this: > > if file.endswith('xyz'): > xyz(file) > elif file.endswith('abc'): >

Re: intolerant HTML parser

2010-02-09 Thread Stefan Behnel
Lawrence D'Oliveiro, 08.02.2010 22:39: > In message <4b6fe93d$0$6724$9b4e6...@newsspool2.arcor-online.net>, Stefan > Behnel wrote: > >> - generating HTML using a tool that guarantees correct HTML output > > Where do you think these tools come from?

Re: use strings to call functions

2010-02-09 Thread Stefan Behnel
Klaus Neuner, 09.02.2010 10:04: > my program is supposed to parse files that I have created myself and that > are on my laptop. It is not supposed to interact with anybody else > than me. Famous last words. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Stephen -- Bruce?

2010-02-09 Thread Stefan Behnel
Mensanator, 05.02.2010 00:36: > On Feb 4, 5:13 pm, "Alf P. Steinbach" wrote: >> What's this about all the Stephen'ses here? >> >> Shouldn't it be Bruce? > > Of course. We just call everyone Stephen to avoid confusion. Some people even manage to adapt the spellings accordingly. Stefan -- http://

Re: Static method

2010-02-18 Thread Stefan Behnel
mk, 18.02.2010 12:12: > I'm trying to get print_internal_date become a static method AND to > refer to it in a class attribute 'tagdata' dict. > > class PYFileInfo(FileInfo): > 'python file properties' > > @staticmethod > def print_internal_date(filename): > f = open(filename

Re: Few questions on SOAP

2010-02-18 Thread Stefan Behnel
joy99, 18.02.2010 16:36: > SOA is an architecture which is now a days governed like XML by W3C. > The latest version is SOAP 1.2. SOA has nothing to do with SOAP. SOAP is a (rather bloated) protocol for remote procedure calls. SOA is a system architecture, be it distributed or not. Stefan -- htt

Re: Executing Python code on another computer

2010-02-19 Thread Stefan Behnel
Dave Angel, 19.02.2010 20:04: > In that case, consider using RemoveDesktop, which is built into both Xp > and Vista. Careful, sounds like malware to me. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading a large bz2 textfile exits early

2010-02-22 Thread Stefan Behnel
Lie Ryan, 22.02.2010 14:29: > On 02/22/10 19:43, Norman Rieß wrote: >> Am 02/22/10 09:02, schrieb Steven D'Aprano: >>> On Mon, 22 Feb 2010 07:49:51 +0100, Norman Rieß wrote: >>> >>> This is the actual code: source_file = bz2.BZ2File(file, "r") for line in source_file:

Re: When will Python go mainstream like Java?

2010-02-23 Thread Stefan Behnel
Chris Rebert, 23.02.2010 06:45: > Indeed. Python is at position 7, just behind C#, in the TIOBE Index: > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html That index is clearly flawed. A language like PHP (whatever that is supposed to be comparable with) can't possibly be on the ris

Re: When will Python go mainstream like Java?

2010-02-25 Thread Stefan Behnel
mk, 24.02.2010 18:30: > On 2010-02-24 03:26, George Sakkis wrote: >>> Well I for one wouldn't want Python to go exactly Java way, see this: >>> >>> http://www.itjobswatch.co.uk/charts/permanent-demand-trend.aspx?s=jav... >>> >>> This is the percentage of job offers in UK where the keyword "Java" >>

Re: why (1, 2, 3) > [1, 2, 3] is true?

2010-02-25 Thread Stefan Behnel
fat bold cyclop, 25.02.2010 14:00: > I tired to google for comparison of tuple to list but i failed. > > Could anyone explain it to me? Both are not equal, so the comparison returns an arbitrary result in Py2. Note that this was fixed in Py3: Python 3.1.1+ (r311:74480, Nov 2 2009, 15:45:00) [G

Re: why (1, 2, 3) > [1, 2, 3] is true?

2010-02-25 Thread Stefan Behnel
fat bold cyclop, 25.02.2010 15:03: >> Both are not equal, so the comparison returns an arbitrary result in Py2. > Thanks, Stefan. If I understand you correctly the comparison is not > valid. > But I wonder if there is any logic behind this (in 2.x). > Is it possible to predict result of this compar

Re: round() function

2010-02-25 Thread Stefan Behnel
Tracubik, 25.02.2010 16:39: > hi all, i've this sample code: > n = 4.499 str(round(n,2)) > '4.5' > > that's right, but what i want is '4.50' to be displayed instead of '4.5'. > Off course i know that 4.5 = 4.50, still i'ld like to have 4.50. > > How can I solve this? Format the number

Re: Python dos2unix one liner

2010-02-27 Thread Stefan Behnel
@ Rocteur CC, 27.02.2010 10:36: > cat file.dos | python -c "import > sys,re;[sys.stdout.write(re.compile('\r\n').sub('\n', line)) for line in > sys.stdin]" >file.unix See: http://partmaps.org/era/unix/award.html Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: stripping fields from xml file into a csv

2010-02-28 Thread Stefan Behnel
Hal Styli, 27.02.2010 21:50: > I have a sed solution to the problems below but would like to rewrite > in python... Note that sed (or any other line based or text based tool) is not a sensible way to handle XML. If you want to read XML, use an XML parser. They are designed to do exactly what you w

Re: Python dos2unix one liner

2010-02-28 Thread Stefan Behnel
Steven D'Aprano, 28.02.2010 09:48: > There ought to be some kind of competition for the least efficient > solution to programming problems That wouldn't be very interesting. You could just write a code generator that spits out tons of garbage code including a line that solves the problem, and the

Re: stripping fields from xml file into a csv

2010-02-28 Thread Stefan Behnel
Roland Mueller, 28.02.2010 13:01: > The stylesheet is test.xsl and the insput data test.xml. The following > Python code the applies the stylesheet on the input data and puts the output > into foo. > > Python code: > #!/usr/bin/python > import sys > import libxml2 > import libxslt > > styledoc =

Re: stripping fields from xml file into a csv

2010-02-28 Thread Stefan Behnel
Hai Vu, 28.02.2010 17:41: > By the way, Stefan, I am using Python 2.6. Do you know the differences > between ElementTree and cElementTree? Use cElementTree, it's implemented in C and a lot faster and more memory friendly. http://effbot.org/zone/celementtree.htm#benchmarks http://codespeak.net/lxm

Re: stripping fields from xml file into a csv

2010-02-28 Thread Stefan Behnel
Hal Styli, 01.03.2010 00:15: > Stefan, I was happy to see such concise code. > Your python worked with only very minor modifications. > > Hai's test xml data *without* the first and last line is close enough > to the data I am using: > > > > > > > > ... quirky. > > I get a large file given

Re: Detecting new removable drives in Linux

2010-03-01 Thread Stefan Behnel
Bart Smeets, 01.03.2010 10:48: > I'm trying to write a script which detects when a new removable drive is > connected to the computer. On #python I was advised to use the > dbus-bindings. However the documentation on this is limited. Does anyone > know of an example of how I can detect new removabl

Re: python 2.6: how to modify a PIL image from C without copying forth and back

2010-03-03 Thread Stefan Behnel
News123, 03.03.2010 01:38: I created a grayscale image with PIL. Now I would like to write a C function, which reads a;most all pixels and will modify a few of them. My current approach is: - transform the image to a string() - create a byte array huge enough to contain the resulting image - ca

Re: python 2.6: how to modify a PIL image from C without copying forth and back

2010-03-03 Thread Stefan Behnel
News123, 03.03.2010 10:37: Stefan Behnel wrote: Take a look at Cython instead, it will allow you to access PIL's image buffer directly, instead of copying the data. It will also simplify and speed up your C wrapper code. I don't know Cython. Having looked at the web site I'm no

Re: Working group for Python CPAN-equivalence?

2010-03-03 Thread Stefan Behnel
Olof Bjarnason, 03.03.2010 13:45: The "Where is CPAN for Python?" question keeps popping up, with answers ranging from "There is no CPAN for Python" and "We already have CPAN for Python" (confusing). It confuses me that you call this "confusing". I'm wondering - is there any work being done

Re: Working group for Python CPAN-equivalence?

2010-03-03 Thread Stefan Behnel
Stefan Behnel, 03.03.2010 13:52: Olof Bjarnason, 03.03.2010 13:45: The "Where is CPAN for Python?" question keeps popping up, with answers ranging from "There is no CPAN for Python" and "We already have CPAN for Python" (confusing). It confuses me that you

Re: SOAP 1.2 Python client ?

2010-03-03 Thread Stefan Behnel
BlueBird, 03.03.2010 17:32: I am looking for a SOAP 1.2 python client. To my surprise, it seems that this does not exist. Does anybody know about this ? SOAP may be an overly bloated protocol, but it's certainly not black magic. It's not hard to do manually if you really need to: http://effb

Re: Partly erratic wrong behaviour, Python 3, lxml

2010-03-04 Thread Stefan Behnel
Jussi Piitulainen, 04.03.2010 11:46: I am observing weird semi-erratic behaviour that involves Python 3 and lxml, is extremely sensitive to changes in the input data, and only occurs when I name a partial result. I would like some help with this, please. (Python 3.1.1; GNU/Linux; how do I find lx

Re: Partly erratic wrong behaviour, Python 3, lxml

2010-03-05 Thread Stefan Behnel
Jussi Piitulainen, 04.03.2010 22:40: Stefan Behnel writes: Jussi Piitulainen, 04.03.2010 11:46: I am observing weird semi-erratic behaviour that involves Python 3 and lxml, is extremely sensitive to changes in the input data, and only occurs when I name a partial result. I would like some help

Re: compiler with python

2010-03-07 Thread Stefan Behnel
mohamed issolah, 06.03.2010 14:07: I want to create a compiler which transform a code like pascal code (that what I do in C) to "quad" In C, I use BISON and FLEX tools. Hi, please stop starting new threads for the same topic. Instead, reply to responses you get. Stefan -- http://mail.pytho

Re: a simple def how-to

2010-03-07 Thread Stefan Behnel
vsoler, 07.03.2010 16:05: Hello, My script starts like this: book=readFromExcelRange('book') house=readFromExcelRange('house') table=readFromExcelRange('table') read=readFromExcelRange('read') ... But I would like to have something equivalent, like... ranges=['book','house','table','read'] fo

Re: The C language like the Python, by the Python and for the Python --- PythoidC

2010-03-07 Thread Stefan Behnel
CHEN Guang, 08.03.2010 06:08: Hi, if you are interested in C-Python mixed programming, please take a look at: http://pythoidc.googlecode.com PythoidC is the C language like the Python, by the Python and for the Python It looks a bit dangerous to me to parse C header files only with regular exp

Re: running a program on many processors

2010-03-07 Thread Stefan Behnel
Martin P. Hellwig, 08.03.2010 03:08: I did read, two years or so ago, that AMD was looking in to something that does just what you say on a cpu level, that is present itself as one logical cpu but underneath there are multiple physical ones. I wouldn't hold my breath though waiting for it. Many

Re: remove element with ElementTree

2010-03-09 Thread Stefan Behnel
Justin Ezequiel, 09.03.2010 10:34: On Mar 9, 11:35 am, tdan wrote: I have been using ElementTree to write an app, and would like to simply remove an element. But in ElementTree, you must know both the parent and the child element to do this. There is no getparent() function, so I am stuck if I

Re: remove element with ElementTree

2010-03-09 Thread Stefan Behnel
tdan, 09.03.2010 04:35: I have been using ElementTree to write an app, and would like to simply remove an element. But in ElementTree, you must know both the parent and the child element to do this. There is no getparent() function, so I am stuck if I only have an element. I am iterating over a

Re: Are there in Python some static web site generating tools like webgen, nanoc or webby in Ruby ?

2010-03-09 Thread Stefan Behnel
KLEIN Stéphane, 09.03.2010 09:30: Today, I've show this static web site generating tools writed in ruby : * http://webgen.rubyforge.org/index.html * http://nanoc.stoneship.org/about/ * http://webby.rubyforge.org/tutorial/ I like this tools, I'm wonder if there are similar tools in Python

Re: Anything like "Effective Java" for Python?

2010-03-10 Thread Stefan Behnel
Chris Withers, 10.03.2010 17:46: kj wrote: Subject line pretty much says it all: is there a book like "Effective Java" oxymoronic, no? Sorry, couldn't resist ;-) Nothing to excuse for. I thought exactly the same thing. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Anything like "Effective Java" for Python?

2010-03-11 Thread Stefan Behnel
James Harris, 11.03.2010 09:30: On 10 Mar, 15:19, kj wrote: Subject line pretty much says it all: is there a book like "Effective Java" for Python. I.e. a book that assumes that readers are experienced programmers that already know the basics of the language, and want to focus on more advanced

Re: file seek is slow

2010-03-12 Thread Stefan Behnel
CHEN Guang, 12.03.2010 08:51: Metalone wrote: I just tried the seek test with Cython. Cython fseek() : 1.059 seconds. 30% slower than 'C' Python f.seek : 1.458 secondds. 80% slower than 'C'. It is amazing to me that Cython generates a 'C' file that is 1478 lines. PythoidC ( http://pythoidc.

Re: file seek is slow

2010-03-12 Thread Stefan Behnel
Metalone, 11.03.2010 23:57: I just tried the seek test with Cython. Cython fseek() : 1.059 seconds. 30% slower than 'C' Python f.seek : 1.458 secondds. 80% slower than 'C'. It is amazing to me that Cython generates a 'C' file that is 1478 lines. Well, it generated an optimised Python interfa

Re: Large regular expressions

2010-03-15 Thread Stefan Behnel
Nathan Harmston, 15.03.2010 13:21: So I m trying to use a very large regular expression, basically I have a list of items I want to find in text, its kind of a conjunction of two regular expressions and a big list..not pretty. However everytime I try to run my code I get this exception: Over

Re: extract occurrence of regular expression from elements of XML documents

2010-03-16 Thread Stefan Behnel
Martin Schmidt, 15.03.2010 18:16: I have just started to use Python a few weeks ago and until last week I had no knowledge of XML. Obviously my programming knowledge is pretty basic. Now I would like to use Python in combination with ca. 2000 XML documents (about 30 kb each) to search for certain

Re: import antigravity

2010-03-16 Thread Stefan Behnel
Lawrence D'Oliveiro, 16.03.2010 08:40: Subtle... Absolutely. Python 2.4.6 (#2, Jan 21 2010, 23:45:25) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import antigravity Traceback (most recent call last): File "", line 1, in ? Imp

Re: C-API PyObject_Call

2010-03-16 Thread Stefan Behnel
moerchendiser2k3, 16.03.2010 17:08: But the stack is empty after PyObject_Call, isnt it? I think Steve was expecting that you wanted to debug into your program, step into the call, and find the line yourself. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: C-API PyObject_Call

2010-03-16 Thread Stefan Behnel
moerchendiser2k3, 16.03.2010 12:52: i have a serious problem and I am looking for a solution. I pass an instance of a class from a file to PyObject_Call. When something fails, I get a full traceback. If it succeeds, I get the return value. Is it possible to get information from which line/file t

Re: C-API PyObject_Call

2010-03-16 Thread Stefan Behnel
moerchendiser2k3, 16.03.2010 19:25: Hi, currently I am not at home, I will post some stuff when I am back. Just the note: I throw an exception with the C API. Looks like that PyObject *result = PyObject_Call(my_isntance, "", NULL); if(result==NULL) { PyErr_Print(); //when this happens, th

Re: import antigravity

2010-03-16 Thread Stefan Behnel
Michael Rudolf, 17.03.2010 00:48: Am 16.03.2010 21:44, schrieb Mark Lawrence: Who actually *IS* running the time machine? Are there any bugs?? My is. And as I'm a lazy hacker: sure. there are bugs. lets just call them features and move on. nothing to see here ;) I'll know it, I'll just know

Re: C++ code generation

2010-03-16 Thread Stefan Behnel
CHEN Guang, 17.03.2010 02:54: - Original Message - From: "Dan Goodman" I'm doing some C++ code generation using Python, and would be interested in any comments on the approach I'm taking. PythoidC ( http://pythoidc.googlecode.com ) is a C code generator (not C++) It would be nice if

Re: Python bindings tutorial

2010-03-17 Thread Stefan Behnel
mikelisa...@gmail.com, 17.03.2010 10:08: Its interesting you've mentioned the hard work involved in this interface (binding to an EXE instead of a DLL). A year or more ago I was looking at interfacing IPMITOOL to python. Do to the problems incurred with swig/python I switched to a running the pro

Re: Python bindings tutorial

2010-03-17 Thread Stefan Behnel
Dave Angel, 17.03.2010 12:14: Stefan Behnel wrote: I think the point here is that executable binaries are not supposed to be used as libraries. Libraries are. That's the difference between a DLL and an executable in the first place. To run an executable, execute it. The subprocess module i

Re: Swapping Content of Two Dictionaries.

2010-03-17 Thread Stefan Behnel
Hatem Oraby, 17.03.2010 12:26: However, consider the case in which the dictionary we are referencing lives in another module: #external.py # #a = {1:"I'am A} import external temp = external.a external.a = b b = temp Looks like the interface of your module is broken. It shouldn't export the tw

Re: C-API PyObject_Call

2010-03-18 Thread Stefan Behnel
moerchendiser2k3, 17.03.2010 23:35: 1) put the line number information into the message string when you raise the exception you mean the line and file information of the C code, right? Funny that you (being the OP) ask *me* what kind of line information *you* want. Stefan -- http://mail.p

Re: import antigravity

2010-03-18 Thread Stefan Behnel
Lawrence D'Oliveiro, 18.03.2010 08:49: In message, Chris Rebert wrote: I see that you published my unobfuscated e-mail address on USENET for all to see. I obfuscated it for a reason, to keep the spammers away. I'm assuming this was a momentary lapse of judgement, for which I expect an apology. O

Re: import antigravity

2010-03-18 Thread Stefan Behnel
Alf P. Steinbach, 18.03.2010 09:53: Path: feeder.eternal-september.org!eternal-september.org!feeder.erje.net!newsfeed.straub-nv.de!news.linkpendium.com!news.linkpendium.com!newsfeeds.ihug.co.nz!lust.ihug.co.nz!ihug.co.nz!not-for-mail From: Lawrence D'Oliveiro Newsgroups: comp.lang.python Subje

Re: C-API PyObject_Call

2010-03-18 Thread Stefan Behnel
moerchendiser2k3, 18.03.2010 14:58: Funny that you (being the OP) ask *me* what kind of line information *you* want. Stefan Well, I need the line/file information of Python : Then please explain what kind of Python line number you expect to find in C code. Hint: providing details often re

Re: C-API PyObject_Call

2010-03-19 Thread Stefan Behnel
moerchendiser2k3, 19.03.2010 14:12: In my case I call a funcion and I would like to get the line where the function returned. for instance: def my_function(): return 3 So I would like to get line 2(in C) somehow. Ok, so you're looking for the C-level trace function in CPython, I guess.

Re: C-API PyObject_Call

2010-03-20 Thread Stefan Behnel
moerchendiser2k3, 20.03.2010 03:01: Yes, the user is able to set a file which contains a function that does what the user wants. > But in a case, I expect a special return value of this function. Ah, ok, that was the important piece of information that you omitted from your previous posts. So

Re: GC is very expensive: am I doing something wrong?

2010-03-22 Thread Stefan Behnel
Lawrence D'Oliveiro, 22.03.2010 00:36: Terry Reedy wrote: No one has discovered a setting of the internal tuning parameters for which there are no bad patterns and I suspect there are not any such. This does not negate Xavier's suggestion that a code change might also solve your problem. Could

Re: GC is very expensive: am I doing something wrong?

2010-03-23 Thread Stefan Behnel
Paul Rubin, 23.03.2010 06:05: Antoine Pitrou writes: "Orders of magnitude worse", in any case, sounds very exaggerated. The worst case can lose orders of magnitude if a lot of values hash to the same bucket. While this is theoretically true, and it's good to be aware of this possibility, co

Re: Unicode blues in Python3

2010-03-23 Thread Stefan Behnel
nn, 23.03.2010 19:46: Actually what I want is to write a particular byte to standard output, and I want this to work regardless of where that output gets sent to. I am aware that I could do open('nnout','w',encoding='latin1').write(mychar) but I am porting a python2 program and don't want to rewr

Re: 'gcc' failed with exit status 1

2010-03-23 Thread Stefan Behnel
JR, 24.03.2010 03:51: I was hoping I could get some help with this issue with getting Cython to work. Earlier I had an issue that said "unable to find vcvarsall.bat" and it turns out there is an active bug report that covers that issue (I have a 64 bit windows system). I still hadn't installed 3.

Re: C-API: Extract information from function object

2010-03-25 Thread Stefan Behnel
Gabriel Genellina, 24.03.2010 17:49: En Wed, 24 Mar 2010 12:09:27 -0300, moerchendiser2k3 escribió: I have a reference to a function and would like to know how to extract information from a function object. Information I am looking for: line and file where this function is from. PyObject_Call

Re: sum for sequences?

2010-03-25 Thread Stefan Behnel
Neil Cerutti, 25.03.2010 13:37: On 2010-03-25, Steven D'Aprano wrote: You might not want to be so glib. The sum doc sure doesn't sound like it should work on lists. Returns the sum of a sequence of numbers (NOT strings) plus the value of parameter 'start' (which defaults to 0). Wha

Re: Revisiting Generators and Subgenerators

2010-03-25 Thread Stefan Behnel
Patrick Maupin, 26.03.2010 04:30: ... and then re-post your document. ... preferably to the python-ideas mailing list. Although it seems to me that this is something that could be explored as a library first - which usually means that people will tell you exactly that on python-ideas and ask

Re: [C-API] malloc error in PyDict_New

2010-03-26 Thread Stefan Behnel
Jonas H., 26.03.2010 20:10: I'm currently diving into Python C programming and I have a problem with `PyDict_New`. My application receives a SIGABRT from malloc every time I execute `PyDict_New`. malloc throws the following error: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((

Re: I'm looking for html cleaner. Example : convert my title => < h1>my title…

2010-03-29 Thread Stefan Behnel
Stéphane Klein, 29.03.2010 10:12: I work on HTML cleaner. I export OpenOffice.org documents to HTML. Next, I would like clean this HTML export files : * remove comment * remove style * remove dispensable tag * ... some difficulty : * convert my text foo bar => my text foo par * convert my tit

Re: newbie with a encoding question, please help

2010-04-01 Thread Stefan Behnel
Mister Yu, 01.04.2010 13:38: i m still not very sure how to convert a unicode object ** u'\xd6\xd0\xce\xc4 ** back to "中文" the string it supposed to be? You are confused. '\xd6\xd0\xce\xc4' is an encoded byte string, not a unicode string. The fact that you have it stored in a unicode string

Re: newbie with a encoding question, please help

2010-04-01 Thread Stefan Behnel
Mister Yu, 01.04.2010 14:26: On Apr 1, 8:13 pm, Chris Rebert wrote: gb2312_bytes = ''.join([chr(ord(c)) for c in u'\xd6\xd0\xce\xc4']) unicode_string = gb2312_bytes.decode('gb2312') utf8_bytes = unicode_string.encode('utf-8') #as you wanted Simplifying this hack a bit: gb2312_bytes = u'\x

Re: off topic but please forgive me me and answer

2010-04-02 Thread Stefan Behnel
Patrick Maupin, 02.04.2010 07:25: On Apr 1, 11:52 pm, Dennis Lee Bieber wrote: On Thu, 01 Apr 2010 22:44:51 +0200, superpollo declaimed the following in gmane.comp.python.general: how much is one half times one half? import math print math.exp((math.log(1) - math.log(2))

Re: Is Unladen Swallow dead?

2010-11-20 Thread Stefan Behnel
Mark Wooding, 19.11.2010 02:35: John Nagle writes: This has been pointed out many times by many people. There's even a PhD thesis on the topic. Without a few restrictions, so that a compiler can at least tell when support for the hard cases is needed, Python cannot be compiled well. Th

Re: Arrays

2010-11-24 Thread Stefan Behnel
Garland Fulton, 24.11.2010 06:55: Is there a way I can define an Array of and unknown size so I can add and remove to or from it? Are arrays immutable? Python has lists and tuples as basic data structures. Tuples are completely immutable, lists are completely mutable. If you want a container

Re: TDD in python

2010-11-28 Thread Stefan Behnel
Rustom Mody, 28.11.2010 11:58: Does anyone know of something like this for python? http://www.vimeo.com/13240481 The page seems to require a recent version of the Flash player. Could you describe what exactly you are looking for? Stefan -- http://mail.python.org/mailman/listinfo/python-lis

Re: Python 3.1.3

2010-11-28 Thread Stefan Behnel
Gnarlodious, 28.11.2010 16:35: Don't know why, but in Terminal the uparrow now gives me: ^[[A which means I no longer have history scrolling. You seem to be mailing from a Mac, is that the system you're having this problem with? Did you build Python yourself or use a provided binary? (and,

Re: Parsing markup.

2010-11-29 Thread Stefan Behnel
Jon Clements, 26.11.2010 13:58: On Nov 26, 4:03 am, MRAB wrote: On 26/11/2010 03:28, Joe Goldthwaite wrote: > I’m attempting to parse some basic tagged markup. The output of the > TinyMCE editor returns a string that looks something like this; > > This is a paragraph withbold andit

Re: SAX unicode and ascii parsing problem

2010-11-30 Thread Stefan Behnel
goldtech, 30.11.2010 22:15: Think I found it, for example: line = 'my big string' line.encode('ascii', 'ignore') I processed the problem strings during parsing with this and it works now. That's not the right way of dealing with encodings, though. You should open the file with a well defined

Re: Calling FORTAN dll functions from Python

2010-12-07 Thread Stefan Behnel
Alex van der Spek, 07.12.2010 12:11: Does anyone know how to call functions from FORTRAN dlls in Python? Is it even possible? Sure, have a look at fwrap and Cython. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python critique

2010-12-10 Thread Stefan Behnel
Jean-Michel Pichavant, 10.12.2010 15:02: the shadow declaration of some python construct in the current scope. print x # raise NameError [x for x in range(10)] # shadow declaration of x print x # will print 9 Note that this is rarely a problem in practice, and that this has been fixed in Pyth

Re: Python critique

2010-12-10 Thread Stefan Behnel
John Nagle, 10.12.2010 21:02: Probably the biggest practical problem with CPython is that C modules have to be closely matched to the version of CPython. There's no well-defined API that doesn't change. Well, there are no huge differences between CPython versions (apart from the Py_ssize_t cha

Re: Python critique

2010-12-10 Thread Stefan Behnel
Benjamin Kaplan, 11.12.2010 00:13: On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita wrote: How narrow are the scopes in Python? Is each block (each level of indentation) a scope? If it is, then I think it is very enough because the other cases can be detected easier or it might not appear at a

Re: Python critique

2010-12-10 Thread Stefan Behnel
John Nagle, 11.12.2010 00:51: On 12/10/2010 3:25 PM, Stefan Behnel wrote: Benjamin Kaplan, 11.12.2010 00:13: On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita wrote: The only scopes Python has are module and function. There's more. Both a lambda, and in Python 3.x, list comprehen

Re: Bind C++ program for use with both Python 2.x and 3.x

2010-12-12 Thread Stefan Behnel
Peter C., 11.12.2010 23:41: Hello, I am looking at the possibility of making a program in C++. The catch is it will require the ability to work with binding for use with scripting in both Python 2.x and 3.x for various tool plugins. Do I read this right that you want your program to be written

Re: PyArg_ParseTuple question

2010-12-15 Thread Stefan Behnel
Mark Wooding, 14.12.2010 21:42: I could have used PySequence_* functions to read the size and items, but that makes error handling more complicated. One could also borrow the references from the underlying list, which would leave the underlying storage for the vector as the only thing to free.

Re: Is text processing with dicts a good use case for Python cross-compilers like Cython/Pyrex or ShedSkin?

2010-12-16 Thread Stefan Behnel
pyt...@bdurham.com, 16.12.2010 21:03: Is text processing with dicts a good use case for Python cross-compilers like Cython/Pyrex or ShedSkin? (I've read the cross compiler claims about massive increases in pure numeric performance). Cython is generally a good choice for string processing, simpl

Re: Read / Write OpenOffice SpreadSheet ?

2010-12-17 Thread Stefan Behnel
Torsten Mohr, 17.12.2010 02:07: i search for a possibility to access OpenOffoce SpreadSheets from Python with a reasonably new version of Python. Can anybody point me to a package that can do this? Have you looked through the relevant PyPI packages? http://pypi.python.org/pypi?%3Aaction=searc

Re: PyUNO [Was: Read / Write OpenOffice SpreadSheet ?]

2010-12-17 Thread Stefan Behnel
Adam Tauno Williams, 17.12.2010 17:02: On Fri, 2010-12-17 at 10:19 +0100, Torsten Mohr wrote: Thanks, i read about it but as i understood it, UNO needs Python 2.3.x and i'd like to base on something actual. I do not *believe* this is true. for ins

Re: Creating custom types from C code

2010-12-17 Thread Stefan Behnel
Eric Frederich, 17.12.2010 23:58: I have an extension module for a 3rd party library in which I am wrapping some structures. My initial attempt worked okay on Windows but failed on Linux. I was doing it in two parts. The first part on the C side of things I was turning the entire structure into a

Re: Creating custom types from C code

2010-12-20 Thread Stefan Behnel
Eric Frederich, 20.12.2010 16:23: I remember reading about named tuples when they were back-ported to the 2.X series but I never played with them. Is there a way to instantiate a named tuple from C code? There isn't a dedicated C-API for named tuples, but you can instantiate any Python type fr

Re: Trying to parse a HUGE(1gb) xml file

2010-12-21 Thread Stefan Behnel
Adam Tauno Williams, 20.12.2010 20:49: On Mon, 2010-12-20 at 11:34 -0800, spaceman-spiff wrote: This is a rather long post, but i wanted to include all the details& everything i have tried so far myself, so please bear with me& read the entire boringly long post. I am trying to parse a ginormou

Re: Trying to parse a HUGE(1gb) xml file

2010-12-21 Thread Stefan Behnel
spaceman-spiff, 20.12.2010 21:29: I am sorry i left out what exactly i am trying to do. 0. Goal :I am looking for a specific element..there are several 10s/100s occurrences of that element in the 1gb xml file. The contents of the xml, is just a dump of config parameters from a packet switch( a

Re: lxml etree question

2010-12-25 Thread Stefan Behnel
Jim, 24.12.2010 16:10: Hello, I wonder if someone knows about lxml.etree and namespaces? I want to build an ElementTree where some of the sub-elements have attributes that serialize this way. .. I've tried just comment_elet.set('xml:lang','de') and it didn't like that at all (although it t

Re: Trying to parse a HUGE(1gb) xml file

2010-12-25 Thread Stefan Behnel
Steve Holden, 25.12.2010 16:55: On 12/23/2010 4:34 PM, Stefan Sonnenberg-Carstens wrote: For large datasets I always have huge question marks if one says "xml". But I don't want to start a flame war. I agree people abuse the "spirit of XML" using it to transfer gigabytes of data I keep readi

Re: Trying to parse a HUGE(1gb) xml file

2010-12-26 Thread Stefan Behnel
Tim Harig, 26.12.2010 02:05: On 2010-12-25, Nobody wrote: On Sat, 25 Dec 2010 14:41:29 -0500, Roy Smith wrote: Of course, one advantage of XML is that with so much redundant text, it compresses well. We typically see gzip compression ratios of 20:1. But, that just means you can archive them e

Re: Trying to parse a HUGE(1gb) xml file

2010-12-26 Thread Stefan Behnel
Tim Harig, 26.12.2010 10:22: On 2010-12-26, Stefan Behnel wrote: Tim Harig, 26.12.2010 02:05: On 2010-12-25, Nobody wrote: On Sat, 25 Dec 2010 14:41:29 -0500, Roy Smith wrote: Of course, one advantage of XML is that with so much redundant text, it compresses well. We typically see gzip

Re: lxml etree question

2010-12-26 Thread Stefan Behnel
Jim, 26.12.2010 00:32: On Dec 25, 5:33 am, Stefan Behnel wrote: lxml knows about this special case, so you can write {http://www.w3.org/XML/1998/namespace}lang and lxml will take care of using the right prefix. Stefan, thank you for the software, which has helped me a great deal

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Stefan Behnel
Alan Meyer, 27.12.2010 21:40: On 12/21/2010 3:16 AM, Stefan Behnel wrote: Adam Tauno Williams, 20.12.2010 20:49: ... You need to process the document as a stream of elements; aka SAX. IMHO, this is the worst advice you can give. Why do you say that? I would have thought that using SAX in

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Stefan Behnel
Roy Smith, 28.12.2010 00:21: To go back to my earlier example of FALSE using 432 bits to store 1 bit of information, stuff like that doesn't happen in marked-up text documents. Most of the file is CDATA (do they still use that term in XML, or was that an SGML-ism only?). The markup i

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Stefan Behnel
Alan Meyer, 28.12.2010 03:18: By the way Stefan, please don't take any of my comments as complaints. I don't. After all, this discussion is more about the general data format than the specific tools. I use lxml more and more in my work. It's fast, functional and pretty elegant. I've writt

Re: Trying to parse a HUGE(1gb) xml file

2010-12-27 Thread Stefan Behnel
Alan Meyer, 28.12.2010 01:29: On 12/27/2010 4:55 PM, Stefan Behnel wrote: From my experience, SAX is only practical for very simple cases where little state is involved when extracting information from the parse events. A typical example is gathering statistics based on single tags - not a very

Re: Interning own classes like strings for speed and size?

2010-12-28 Thread Stefan Behnel
Steven D'Aprano, 28.12.2010 15:11: On Tue, 28 Dec 2010 13:42:39 +0100, Ulrich Eckhardt wrote: Steven D'Aprano wrote: class InternedTuple(tuple): ... _cache = {} ... def __new__(cls, *args): ... t = super().__new__(cls, *args) ... return cls._cache.setdefault(t,

Re: Removing an attribute from html with Regex

2010-12-30 Thread Stefan Behnel
Selvam, 30.12.2010 08:30: I have some HTML string which I would like to feed to BeautifulSoup. But, One malformed attribute breaks BeautifulSoup. My String Didn't try with BS (and you forgot to say what "breaks" means exactly in your case), but it parses in a somewhat reasonable way w

Re: Digitally Signing a XML Document (using SHA1+RSA or SHA1+DSA)

2010-12-30 Thread Stefan Behnel
Jorgen Grahn, 30.12.2010 10:41: If you really *do* have a requirement to make the result XML-like and incompatible with anything else, I'm afraid you're on your own Well, there's always xmlsec if you need it. http://www.aleksey.com/xmlsec/ Stefan -- http://mail.python.org/mailman/listinfo/py

<    9   10   11   12   13   14   15   16   17   18   >