Re: Function Overloading and Python

2008-02-25 Thread Stefan Behnel
Allen Peloquin wrote: > On Feb 24, 11:44 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote: >> Allen Peloquin wrote: >>> class B >>> { >>> fun(A x, A y, A z)... >>> fun(A1 x, A y, A z)... >>> } >>> class B1 >>>

Re: XML expat error

2008-02-28 Thread Stefan Behnel
dirkheld wrote: > On 28 feb, 08:18, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Wed, 27 Feb 2008 14:02:25 -0800, dirkheld wrote: >>> Something strange here. The xml file causing the problem has only 361 >>> lines. Isn't there a way to catch this error, ignore it and continu >>> with t

Re: xsd, data binding. Modern approach?

2008-02-29 Thread Stefan Behnel
Vladimir Kropylev wrote: > What is the most actual approach to python XML data-binding? > The answers given by google seam to be rather outdated. Can't believe > nothing's changed since 2003. > > To be concrete, i've faced the following task: > I HAVE: > - XSD schema (a huge collection of *.xsd fi

Re: XML Schema validation in Python

2008-03-04 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > I tested and tried a few XML validators but none of them is able to > successfully validate a string of xml (not a file just a string) to > programatically be able to validate messages of xml that flow in and > out of the different systems. http://codespeak.net/lxml/tuto

Re: generateDS problem: __init__ of base class is not called (processing linked xsd files)

2008-03-06 Thread Stefan Behnel
Vladimir Kropylev wrote: > Is it possible to have __init__ of superclass called when superclass > and subclass are defined in different XSD files? > There's no problem when super and subclass are defined within single XSD file. > > In another words, can generateDS correctly process schema, describ

Re: Looking for very light weight template library (not framework)

2008-03-07 Thread Stefan Behnel
Jeff McNeil wrote: > Isn't there some long > running joke about new Python programmers creating their own template > language or something, too? =) http://article.gmane.org/gmane.comp.python.general/544922 Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Distributed App - C++ with Python for Portability?

2008-03-10 Thread Stefan Behnel
Matt Nordhoff wrote: > For what you do decide to rewrite in C, you can also use a language like > Cython [1] (which is a fork of Pyrex [2]). It looks mostly like Python, > and is translated to C without you having to write all of the > boilerplate Python C API stuff. Of course, not quite as efficie

Re: Distributed App - C++ with Python for Portability?

2008-03-10 Thread Stefan Behnel
Matt Nordhoff wrote: > Stefan Behnel wrote: >> And if you really need the efficiency of "well-tuned raw C", it's one >> function >> call away in your Cython code. > > What do you mean by that? > > I know nothing about how Cython compares to C in

Re: How to create Python object in C/C++ extension by class name?

2008-03-10 Thread Stefan Behnel
Neil.Fang.CN wrote: > I'm trying to write a C++ extension like this: > > //--- > // C++ code > class ActorBase > {...}; > > // export ActorBase to Python as a new type > > class ActorManager > { > void addNewActor(const char*

Re: Quality assurance in Python projects containing C modules

2008-03-10 Thread Stefan Behnel
Duncan Booth wrote: > [EMAIL PROTECTED] wrote: >> We are thinking about writing a project for several customers in >> Python. This project would include (among others) wxPython, a C/C++ >> module. But what happens if this application generates a segmentation >> fault on a customers PC. What changes

Re: wxPython/wxWidgets ok for production use ?

2008-03-10 Thread Stefan Behnel
Malcolm Greene wrote: >> My personal experience with wxPython has its ups and downs. Specifically >> when it comes to crashes, I wouldn't bet my life on it. > > I'm new to Python and getting ready to build a small client based > application intended to run on Windows and Linux. I was planning on

Re: Quality assurance in Python projects containing C modules

2008-03-10 Thread Stefan Behnel
Duncan Booth wrote: > Stefan Behnel <[EMAIL PROTECTED]> wrote: >> Duncan Booth wrote: >>> I would start by ensuring that any DLLs you write are written using >>> Pyrex or Cython: almost always problems with C libraries called from >>> Python are due to fau

Re: Distributed App - C++ with Python for Portability?

2008-03-10 Thread Stefan Behnel
Bob Martin wrote: > Java is more portable than most other languages, especially if your app needs > a gui. I don't think anything is more portable for an App GUI than HTML through a built-in web server. That said, does gcj compile GUI Apps by now? Or does that not count as "portable"? Stefan -

Re: Python PDF + Pictures

2008-03-11 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > I have many photos, and I wanna make some "presentation" from these > photos, a "thumbnail" like document with one image per one page. > > If I wanna make one document now I do this: > I execute a python script that create a html site with resized pictures, > and split t

Re: wxPython/wxWidgets ok for production use ?

2008-03-11 Thread Stefan Behnel
Sion Arrowsmith wrote: > And before you blame wx* for crashes: what platform was this on? > Because my experience was that wx on GTK was significantly more prone > to glitches than on Windows (through to wxglade being unusably crashy) > -- if the underlying toolkit has problems, that's going to be

Re: Python - CGI - XML - XSD

2008-03-12 Thread Stefan Behnel
xkenneth wrote: > On Mar 12, 6:32 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> xkenneth wrote: >>> Hi All, >>>Quick question. I've got an XML schema file (XSD) that I've >>> written, that works fine when my data is present as an XML file. >>> (Served out by apache2.) Now when I call pyt

Re: sorting question

2008-03-14 Thread Stefan Behnel
Steven D'Aprano wrote: > On Thu, 13 Mar 2008 22:37:00 -0500, "Andrew Rekdal" wrote: > >> Seems 'KEYBOARDS' works nicely > > in reply to a post from "jcnbp8k" who wrote: > >>> That's easy solved, the word is keyboards. > > Hmmm... using my incredible powers of deduction, I predict that the word

Re: Types, Cython, program readability

2008-03-16 Thread Stefan Behnel
Hi, [EMAIL PROTECTED] wrote: > It seems Cython is going to become an efficient and > general purpose language after all, with optional static typing (its > purpose: mostly for speed), and it may even gain some kind of macros > soon. So it may even end replacing Python itself in some situations > w

Re: Types, Cython, program readability

2008-03-16 Thread Stefan Behnel
sturlamolden wrote: > On 16 Mar, 15:32, [EMAIL PROTECTED] wrote: >> It seems the development of Cython is going very well, quite >> differently from the dead-looking Pyrex. Hopefully Cython will become >> more user-friendly too (Pyrex is far from being user-friendly for >> Windows users, it doesn't

Re: Issues with XMLTreeBuilder in cElementTree and ElementTree

2008-03-23 Thread Stefan Behnel
Michael Becker wrote: > Secondly, I found a potential issue with the cElementTree module. My > understanding (which could be incorrect) of python C modules is that > they should work the same as the python versions but be more > efficient. The XMLTreeBuilder class in cElementTree doesn't seem to be

Re: Element Tree Help

2008-03-24 Thread Stefan Behnel
Robert Rawlins wrote: > Hello Guys,I have little to no experiance with element tree and I'm > struggling to find a way to parse the details from the XML document > (attached) into my application. Essentialy I'm looking to take the > following document and turn it into a dict of tuples, each dict el

Re: Element Tree Help

2008-03-24 Thread Stefan Behnel
Stefan Behnel schrieb: > Robert Rawlins wrote: >> Hello Guys,I have little to no experiance with element tree and I'm >> struggling to find a way to parse the details from the XML document >> (attached) into my application. Essentialy I'm looking to take the >>

Re: URL encoding

2008-03-24 Thread Stefan Behnel
binaryj wrote: > On Mar 24, 7:04 pm, [EMAIL PROTECTED] wrote: >> Is there any method in the standard modules that can perform proper >> url encoding according to RFC? > > whats wrong with the current encoding ??? it just works fine!!! > > or is it that u dont know about urllib.urlencode() ?? I t

Re: Beautiful Soup Looping Extraction Question

2008-03-25 Thread Stefan Behnel
Hi, again, not BS related, but still a solution. Tess wrote: > Let's say I have a file that looks at file.html pasted below. > > My goal is to extract all elements where the following is true: align="left"> and . Using lxml: from lxml import html tree = html.parse("file.html") for el in

Re: Psyco alternative

2008-03-27 Thread Stefan Behnel
king kikapu wrote: >>> As for psyco, are there any alternatives to use now ? >> But ultimately, the author says that the approach is flawed, so at *some* >> point it will be discontinued. But that could be said about nearly >> everything, couldn't it? >> > It is a pity because this module *does* re

Re: "Soup Strainer" for ElementSoup?

2008-03-27 Thread Stefan Behnel
erikcw wrote: > I'm parsing real-world HTML with BeautifulSoup and XML with > cElementTree. > > I'm guessing that the only benefit to using ElementSoup is that I'll > have one less API to keep track of, right? If your "real-world" HTML is still somewhat close to HTML, lxml.html might be an option

Re: Problems in Using C-API for Unicode handling

2009-01-13 Thread Stefan Behnel
abhi wrote: > Now I want to utf-16 so I am trying to use the first one, but it is > giving back NULL in case of PyObject is already Unicode type which is > expected. What puzzles me is that PyUnicode_FromObject(PyObject *obj) > is passing irrespective of type of PyObject. The API says it is > Short

Re: changing URLs in webpages, python solutions?

2009-01-18 Thread Stefan Behnel
Simon Forman wrote: > I want to take a webpage, find all URLs (links, img src, etc.) and > rewrite them in-place, and I'd like to do it in python (pure python > preferred.) lxml.html has functions specifically for this problem. http://codespeak.net/lxml/lxmlhtml.html#working-with-links Code woul

Re: Python and threads

2009-01-18 Thread Stefan Behnel
vedrandeko...@yahoo.com wrote: > Thanks for previous help on "Start two threads in same time" it was > useful,but when I run this > two threads, I think they don't start at the same time That's normal. Threading is an unpredictable concurrency pattern. Things often don't happen the way one would w

Re: Python and threads

2009-01-18 Thread Stefan Behnel
vedrandeko...@yahoo.com wrote: > and thanks for all previous help.I want to measure memory usage of > executed python script.I'am working on windows XP. Could you qualify "measure"? Do you mean: a) "debug" (permanently high accuracy, potentially high runtime overhead) b) "monitor" (high accuracy,

Re: Parsing XML: SAX, DOM, Expat, or Something Else?

2009-01-23 Thread Stefan Behnel
Chris Rebert wrote: > On Fri, Jan 23, 2009 at 11:19 AM, aha wrote: >> I've been charged with developing an XML configuration file format, >> for one of the applications that my company develops. >> [...] >> I am still trying to determine the >> best XML parser API to use. I would love to use XPAT

Re: search speed

2009-01-30 Thread Stefan Behnel
D'Arcy J.M. Cain wrote: > On Fri, 30 Jan 2009 15:46:33 +0200 > Justin Wyer wrote: >> $ find -name "*" -exec grep -nH "LF01" {} \; >> | cut -d ":" -f 1 | sort | uniq > > I know this isn't a Unix group but please allow me to suggest instead; > > $ grep -lR LF01 That's a very good advice. I ha

Re: search speed

2009-01-30 Thread Stefan Behnel
Diez B. Roggisch wrote: > that's not necessarily the best thing to do if things have a > record-like structure. The canonical answer to this is then to use a > database to hold the data, instead of flat files. So if you have any > chance to do that, you should try & stuff things in there. It's wor

Re: Using lxml to screen scrap a site, problem with charset

2009-02-04 Thread Stefan Behnel
Tim Arnold wrote: > "?? ???" wrote in message > news:ciqh56-ses@archaeopteryx.softver.org.mk... >> So, I'm using lxml to screen scrap a site that uses the cyrillic >> alphabet (windows-1251 encoding). The sites HTML doesn't have the > ..content-type.. charset=..> header, but does

Re: Python Integrated Parallel Pipeline EnviRonment: PIPPER

2009-02-05 Thread Stefan Behnel
Kyle wrote: > def do_call(x,y): > print "Hello World", x, y, os.getpid() > > if __name__ == '__pipper_main__': > a_range = range( int(sys.argv[1]) ) > #pragma pipper_start > for a in a_range : > for b in a_range : > do_call(a,b) >

Re: ElementTree and clone element toot

2009-02-08 Thread Stefan Behnel
Aahz wrote: > In article <4986bfd7$0$9385$ba4ac...@news.orange.fr>, > m.banaouas wrote: >> Working with the ElementTree module, I looked for clone element >> function but not found such tool: > > Have you tried using copy.deepcopy()? While being the most obvious solution, calling deepcopy() on a

Re: ImportError: dynamic module does not define init function (inittypes)

2009-02-15 Thread Stefan Behnel
konteya joshi wrote: > I see the following error on running the program: > > 'import site' failed; use -v for traceback > Traceback (most recent call last): > File "skyline\alpine_kickoff.py", line 6, in ? > import re > File "C:\Perforce\qa\testware\build\vmqa\python\python-2.4.1-as\lib\re

Re: What encoding does u'...' syntax use?

2009-02-20 Thread Stefan Behnel
Ron Garret wrote: > I would have thought that the answer would be: the default encoding > (duh!) But empirically this appears not to be the case: > unicode('\xb5') > Traceback (most recent call last): > File "", line 1, in > UnicodeDecodeError: 'ascii' codec can't decode byte 0xb5 in pos

Re: What encoding does u'...' syntax use?

2009-02-20 Thread Stefan Behnel
Stefan Behnel wrote: >>>>> print u'\xb5' >> µ > > What you > see in the last line is what the Python interpreter makes of your unicode > string when passing it into stdout, which in your case seems to use a > latin-1 encoding (check your envi

Re: Python dictionary size/entry limit?

2009-02-21 Thread Stefan Behnel
intellimi...@gmail.com wrote: > I wrote a script to process textual data and extract phrases from > them, storing these phrases in a dictionary. It encounters a > MemoryError when there are about 11.18M keys in the dictionary, and > the size is about 1.5GB. > [...] > I have 1GB of pysical memory an

Re: TypeError: descriptor 'replace' requires a 'str' object but received a 'unicode'

2009-02-21 Thread Stefan Behnel
Jaap van Wingerde wrote: > # -*- coding: utf_8 -*- > Omschrijving = u'priv? assuranti?n' # string from a bank.csv > Omschrijving = str.replace(Omschrijving, "priv?", 'privé') > Omschrijving = str.replace(Omschrijving, "Assuranti?n", 'Assurantiën') > print Omschrijving > > When I run this script I

Re: ordinal not in range

2009-02-21 Thread Stefan Behnel
Jaap van Wingerde wrote: > Stefan Behnel wrote: >> Omschrijving = Omschrijving.replace("priv?", 'privé') actually, make that Omschrijving = Omschrijving.replace(u"priv?", u'privé') (mind the u"...") > > import c

Re: Python dictionary size/entry limit?

2009-02-22 Thread Stefan Behnel
intellimi...@gmail.com wrote: > Ummm, I didn't know about the dbm databases. It seems there are many > different > modules for this kind of tasks: gdbm, berkeley db, cdb, etc. I'm > needing to implement > a constant hashtable with a large number of keys, but only a small > fraction of them > will b

Re: how to detect if a dictionary has been modified ?

2008-11-23 Thread Stefan Behnel
Steven D'Aprano wrote: > What does the S stand for? The S stands for simple. http://wanderingbarque.com/nonintersecting/2006/11/15/the-s-stands-for-simple/ Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: what's so difficult about namespace?

2008-11-26 Thread Stefan Behnel
Glenn Linderman wrote: > it appears the > OP understands that issue, and is asking why languages without > namespaces don't add them. Note that Xah Lee is not generally someone who (or something that) "asks" in order to learn something or to understand issues better. The more general interest appe

Re: Python C/API simple debugging

2008-11-26 Thread Stefan Behnel
k3xji wrote: > I am new to Python C API and finding it difficult to debug C > extensions. So, basically I want to see the value of an integer value > during the C API. Here is the code: > > #define LAST_MIX_VAL 0xDEADBEEF > > static PyObject * > chash(PyObject *self, PyObject *args) > { > uns

Re: what's so difficult about namespace?

2008-11-26 Thread Stefan Behnel
Xah Lee wrote: >> The IT community has enough trouble getting a few ISPs to upgrade their >> DNS software. How are you going to get millions of general users to >> upgrade? > > alright, that's speaks for Javascript. > > But how's that apply to, say, Scheme lisp, Emacs lisp, PHP? Think before you

Re: iterating over a variable which could be None, a single object, or a list

2008-11-27 Thread Stefan Behnel
adam carr wrote: > I call a function get_items() which returns a list of items. > However, in some cases, it returns just one item. > It returns the item as an object though, not as a list containing one object. > In other cases it simply returns None. > > What is the cleanest way to iterate over

Re: Exhaustive Unit Testing

2008-11-27 Thread Stefan Behnel
Steven D'Aprano wrote: > If you don't test all the paths, then by definition you > have program paths which have never been tested. Unless those paths are > so trivially simple that you can see that they must be correct just by > looking at the code, then the chances are very high that they will

Re: Is there any project whose patches are all available?

2008-11-27 Thread Stefan Behnel
ZelluX wrote: > For example, by comparing two versions of a program, may be we can > generate some scripts to direct the virtual machine update a running > python program. I had to read this sentence a couple of times, as it sounds too much like StarTrek speak. My guess is that you are talking ab

Re: Is there any project whose patches are all available?

2008-11-27 Thread Stefan Behnel
Stefan Behnel wrote: > I think what you have in mind is that smaller changes make code reload > easier than bigger changes, especially API changes. ... or ABI changes in the general case, although that's not a major difference in the Python context. Stefan -- http://mail.python.

Re: Reverse zip() ?

2008-12-02 Thread Stefan Behnel
Andreas Waldenburger wrote: > we all know about the zip builtin that combines several iterables into > a list of tuples. > > I often find myself doing the reverse, splitting a list of tuples into > several lists, each corresponding to a certain element of each tuple > (e.g. matplotlib/pyplot needs

Re: Reverse zip() ?

2008-12-02 Thread Stefan Behnel
Zac Burns wrote: > More succinct failure: > > keys, values = zip(*{}.iteritems()) Simple fix: some_iterable = {}.iteritems() keys, values = zip(*list(some_iterable)) or: keys, values = zip(*(some_iterable if isinstance(some_iterable, (list, tuple))

Re: Python C API

2008-12-05 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > The first question is, I found out the API contains other commands lik > PyEval_AcquireLock(). I don't really understand if I have to use them > too, could anyone explain? Thanks. That's unrelated. The GIL is special in that it has its own handling functions. > void My

Re: Small problem with Psyco

2008-12-05 Thread Stefan Behnel
[EMAIL PROTECTED] wrote: > I post it here because I am using a Psyco version that was compiled by > people here. > I am using Python 2.6.1, on Win, with Psyco (1, 6, 0, 'final', 0). > > This minimized code: > > from psyco.classes import psyobj > class Bar(psyobj): > def __init__(self, baz): >

Re: Don't you just love writing this sort of thing :)

2008-12-06 Thread Stefan Behnel
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Arnaud Delobelle wrote: > >> * you seem to disregard the fact that in 'programming language' there >> is the word 'language'. A language is a way to _communicate_ >> information, in the case of a programming language you commu

Re: Python is slow

2008-12-12 Thread Stefan Behnel
David Cournapeau wrote: > I want faster function > calls to use with numpy: do you know of any solution ? http://cython.org/ Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is slow

2008-12-12 Thread Stefan Behnel
sturlamolden wrote: > How is the numpy support in Cython going? It was supposed to know > about ndarrays natively. It does. > I.e. not treat them as Python objects, but > rather as known C structs. That way an operation like arr[n] would not > result in a callback to Python, but translate direct

Re: C API and memory allocation

2008-12-17 Thread Stefan Behnel
Floris Bruynooghe wrote: > I'm slightly confused about some memory allocations in the C API. If you want to reduce the number of things you have to get your head around, learn Cython instead of the raw C-API. It's basically Python, does all the reference counting for you and also reduces the amoun

Re: C API and memory allocation

2008-12-18 Thread Stefan Behnel
Aaron Brady wrote: > I see. Do I read correctly that 's' is only useful when the > argument's position is known? I assume you meant "length". > Otherwise you can't know its length or > change its reference count. The internal representation of Python byte strings is 0 terminated, so strlen()

Re: C API and memory allocation

2008-12-19 Thread Stefan Behnel
Aaron Brady wrote: >>> Otherwise you can't know its length or change its reference count. >> The internal representation of Python byte strings is 0 terminated, so >> strlen() will work. > > As MRAB said, Python strings can contain null bytes, Sure, they can. Most byte strings I've seen didn't,

Re: ANN: New Book: Programming in Python 3

2008-12-19 Thread Stefan Behnel
Thomas Heller wrote: > Mark Summerfield schrieb: >> Just a follow-up to say that the book has now been published in the >> U.S. >> It is now in stock at InformIT, and should reach other stores, e.g., >> Amazon, in a week or so. >> >> Also, the introduction, the first few pages of the first chapter,

Re: New Python 3.0 string formatting - really necessary?

2008-12-20 Thread Stefan Behnel
Steven D'Aprano wrote: > I have no objection to > the addition of the format() method (although I wonder whether it might > have been better as a function). I actually learned about the String.format() method in Java a while after having read about str.format() in Python, and my first reaction w

Re: Getting a locked buffer from objects (PEP 3118)

2008-12-27 Thread Stefan Behnel
KKH wrote: > it seems the whole locking-theme has gone from PEP 3118 (PyBUF_LOCK is > gone). Yet the string and byte objects seem to provide locked buffers > through PyArg_Parse arguments s*, y* and z* (documentation says so). Might be a left-over. All locking the buffer interface itself provides

Re: Any equivalent to Ruby's 'hpricot' html/xpath/css selector package?

2008-12-30 Thread Stefan Behnel
Mark Thomas wrote: > The main difference is that lxml doesn't have CSS selector syntax Feel free to read the docs: http://codespeak.net/lxml/cssselect.html Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Any equivalent to Ruby's 'hpricot' html/xpath/css selector package?

2008-12-30 Thread Stefan Behnel
Bruno Desthuilliers wrote: >> However, what makes it really useful is that it does a good job of >> handling the "broken" html that is so commonly found on the web. > > BeautifulSoup ? > http://pypi.python.org/pypi/BeautifulSoup/3.0.7a > > possibly with ElementSoup ? > http://pypi.python.org/pypi

Re: Any equivalent to Ruby's 'hpricot' html/xpath/css selector package?

2008-12-30 Thread Stefan Behnel
Kenneth McDonald wrote: > Ruby has a package called 'hpricot' which can perform limited xpath > queries, and CSS selector queries. However, what makes it really useful > is that it does a good job of handling the "broken" html that is so > commonly found on the web. Does Python have anything simila

Re: Python in C

2008-12-30 Thread Stefan Behnel
akineko wrote: > The more you work on Python, the harder you can go back to C or C++ > world. > > I use SWIG, instead. I think SWIG is a good way to mix two worlds. If you find it hard to go from Python back to C, you should have a look at Cython. http://cython.org/ Stefan -- http://mail.python

Re: Which SOAP module?

2009-01-04 Thread Stefan Behnel
Ralf Schoenian wrote: > Roy Smith wrote: >> I'm starting to play with SOAP. The zeroth question that needs >> answering is, "Which SOAP module should I use?" There seem to be a >> number of different ones to pick from. Any suggestions? > > for the server I think you > have to rely on the ZSI (ht

Re: Extending Python with C or C++

2009-01-06 Thread Stefan Behnel
Ryan wrote: > 3. Extending CPython by connecting it to Python-oblivious code written > in C with Ctypes (Ralf's suggestion is good for this) > 4. Extending CPython by connecting it to Python-aware (and specific) > code using the CPython C-API functions (http://docs.python.org/c-api/) For extending

Re: Any news on when some libraries will be ported to Python 3.0?

2009-01-07 Thread Stefan Behnel
Just Another Victim of the Ambient Morality wrote: > I'm excited to use Python 3.0 (foolishly, it's the only Python > interpreter I have on my system) but there are no libraries for it beyond > the kitchen sink. Personally, a good start would be Beautiful Soup and > Mechanize. I could also

Re: Problem with cPickle and cElementTree

2008-10-09 Thread Stefan Behnel
Barry wrote: > I recently tried switching from ElementTree to cElementTree. My > application parses a collection of large XML files and creates indexes > based on certain attributes. This entire collection is saved as an > instance of my Database class. Using ElementTree and cPickle has > allowe

Re: Implementing my own Python interpreter

2008-10-14 Thread Stefan Behnel
Ognjen Bezanov wrote: > Also, any pro's out there willing to chime on the feasibility of > implementing python to run directly on the hardware (without an > underlying OS)? I don't expect 100% compatibility, but would the basics > (branching, looping, arithmatic) be feasible? You should take a loo

Re: C API with *args and **kw

2008-10-14 Thread Stefan Behnel
Miki wrote: > I'm try to write the C equivalent of: > > def kw(*args, **kw): > print "%d args" % len(args), > if "default" in kw: > print "default is %s" % kw["default"] > else: > print "no default" Consider using Cython instead, it will make your life a lot easier. Th

Re: xml.etree.ElementTree and XPath

2008-10-18 Thread Stefan Behnel
xkenneth wrote: > Can I execute XPath queries on ElementTree objects ignoring the > namespace? IE './node' instead of './{http://namespace.com}node'. The XPath support in ET is very limited. You can use lxml.etree instead, which has full support for XPath 1.0, i.e. you can do tree.xpath('

Re: 2.6, 3.0, and truly independent intepreters

2008-10-24 Thread Stefan Behnel
Terry Reedy wrote: > Everything in DLLs is compiled C extensions. I see about 15 for Windows > 3.0. Ah, weren't that wonderful times back in the days of Win3.0, when DLL-hell was inhabited by only 15 libraries? *sigh* ... although ... wait, didn't Win3.0 have more than that already? Maybe you me

Re: Urllib vs. FireFox

2008-10-24 Thread Stefan Behnel
Gilles Ganault wrote: > After scratching my head as to why I failed finding data from a web > using the "re" module, I discovered that a web page as downloaded by > urllib doesn't match what is displayed when viewing the source page in > FireFox. > > For instance, when searching Amazon for "Wargam

Re: lxml removing tag, keeping text order

2008-10-25 Thread Stefan Behnel
Tim Arnold schrieb: > Hi, > Using lxml to clean up auto-generated xml to validate against a dtd; I need > to remove an element tag but keep the text in order. For example > s0 = ''' > >first text > ladida > emphasized text > middle text > > last text > > ''' > > I wan

Re: project in python

2008-10-25 Thread Stefan Behnel
asit wrote: > I am a newbie and learned python to some extent. > > I want to do some project in python based on network programming or > HTML/XML parsing. > > Can anyone suggest me about this ??? The more you spam people with your repetitive postings, the less likely it becomes that they are wil

Re: XML-RPC

2008-10-26 Thread Stefan Behnel
asit wrote: > what is XML-RPC System Doesn't Wikipedia tell you that? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: parse a table in HTML page.

2008-10-28 Thread Stefan Behnel
antonio_wn8 wrote: > I have a need to read and parse a table in HTML page. > > I’m using the following script: > http://trac.davidgrant.ca/browser/src/python/misc/siteuptime/TableParser.py > > It works fine aside from link in href. > > Example: > > String to parse: > elognormal text > > Outp

Re: HTML File Parsing

2008-10-28 Thread Stefan Behnel
Felipe De Bene wrote: > I'm having problems parsing an HTML file with the following syntax : > > > User ID > Name BGCOLOR='#c0c0c0'>Date > and so on > > whenever I feed the parser with such file I get the error : > > HTMLParser.HTMLParseError: bad end tag: "", at > line 515, column

Re: beutifulsoup

2008-10-29 Thread Stefan Behnel
Peter Pearson wrote: > Like you, I struggle with BeautifulSoup Well, there's always lxml.html if you need it. http://codespeak.net/lxml/ Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: remote unzip

2008-11-01 Thread Stefan Behnel
morecowbell wrote: > i got a bunch of zip files on a remote server and need to get to one > of the files, an xml file, in each of the archives. fairly simple to > do locally with zipfile but i don't seem to be able to combine that > local code with the paramiko sftp client. a rather simplified code

Re: encoding in lxml

2008-11-03 Thread Stefan Behnel
jasiu85 wrote: > I have a problem with character encoding in LXML. Here's how it goes: > > I read an HTML document from a third-party site. It is supposed to be > in UTF-8, but unfortunately from time to time it's not. You can instantiate your own HTML parser and pass encoding="utf-8". That way,

Re: python_and_WSDL

2008-11-04 Thread Stefan Behnel
Dejan Pangercic wrote: > question is, does anyone know about any up2date equivalent for > connecting to WSDL from python? It seems like you missed soaplib. Compared to other Python SOAP libraries, it's pretty easy to use. Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: convert to XMLRPC

2008-11-06 Thread Stefan Behnel
Michel Perez wrote: > [db connection] > In the stdlib xmlrpclib handles this in a common way, but i use a > customized GatewayHandler that give me the posibility to serialize my > objects and send them to my clients Doesn't XML-RPC do that for you already? What's the protocol you use for client co

Re: need money for comp. shit?

2008-11-06 Thread Stefan Behnel
bslobodi wrote: > [spam stripped] Sorry, I didn't find comp.shit on Gmane. Did you mean comp.shell or something in that line? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Workflow engine?

2008-11-08 Thread Stefan Behnel
Grzegorz Staniak schrieb: > On 08.11.2008, Tino Wildenhain <[EMAIL PROTECTED]> wroted: > >>> In a couple of weeks I'm starting a medium-size project (using a web >>> framework) involving a workflow implementation. Are you aware of any >>> open source workflow engines/libraries that I could base

Re: Python 3.0 - is this true?

2008-11-09 Thread Stefan Behnel
Kay Schluehr wrote: > On 9 Nov., 07:06, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> How often do you care about equality ignoring order for lists containing >> arbitrary, heterogeneous types? > > A few times. Why do you care, Steven? "I miss this feature" is an unqualified

Re: Python 3.0 - is this true?

2008-11-09 Thread Stefan Behnel
Duncan Booth wrote: > Roy Smith wrote: > >> In 3.0, can you still order types? In 2.x, you can do: >> > t1 = type(1) > t2 = type(1j) > t1 < t2 >> False >> >> If this still works in 3.0, then you can easily do something like: >> >> def total_order(o1, o2): >>"Compare any two object

Re: ElementTree XML Namspace

2008-11-15 Thread Stefan Behnel
Hunter wrote: > We are reviewing a vendor who will output some data in an XML format. > I will then use python to convert the data to another format for > upload to another vendor. Take a look at lxml.objectify, it has a nicer API, especially if you are new to XML. It also handles loads of namespa

Re: Cython Installation on Windows

2008-11-18 Thread Stefan Behnel
Srijit Kumar Bhadra wrote: > Cython Installation on Windows documentation (http://wiki.cython.org/ > InstallingOnWindows) needs a minor but important change. > > Under section "MinGW Compiler" [build] compiler = mingw32 should be > replaced by the following lines (i.e. disutils.cfg should have the

Re: regular expressions ... slow

2008-11-18 Thread Stefan Behnel
Kay Schluehr wrote: > All of this is prototyped in Python and it is still work in progress. > As long as development has not reached a stable state I refuse to > rebuild the system in an optimized C version. And rightfully so: 1) the approach is algorithmically better, so it may even beat the cur

Re: XML -> Tab-delimited text file (using lxml)

2008-11-19 Thread Stefan Behnel
Gibson wrote: > I'm attempting to do the following: > A) Read/scan/iterate/etc. through a semi-large XML file (about 135 mb) > B) Grab specific fields and output to a tab-delimited text file > [...] > out = open('output.txt','w') > cat = etree.parse('catalog.xml') Use iterparse() instead of pa

Re: Python C-API Object Allocation

2009-02-24 Thread Stefan Behnel
> On Feb 21, 2009, at 10:01 AM, William Newbery wrote: >> Ive been learning the C-API lately so I can write python extensions >> for some of my c++ stuff. First thing that comes to (my) mind is that you probably do not want to write code against the bare C-API. Instead, give Cython a try. http://

Re: Python dictionary size/entry limit?

2009-02-25 Thread Stefan Behnel
Martin v. Löwis wrote: > intellimi...@gmail.com wrote: >> Is there a limit to the size or number of entries that a single >> dictionary can possess? > > On a 32-bit system, the dictionary can have up to 2**31 slots, > meaning that the maximum number of keys is slightly smaller > (about 2**30). W

Re: removing duplication from a huge list.

2009-02-27 Thread Stefan Behnel
bearophileh...@lycos.com wrote: > odeits: >> How big of a list are we talking about? If the list is so big that the >> entire list cannot fit in memory at the same time this approach wont >> work e.g. removing duplicate lines from a very large file. > > If the data are lines of a file, and keeping

Re: How to parse form in client side?

2009-02-27 Thread Stefan Behnel
Muddy Coder wrote: > cgi module can easily acquire the all fields of data input from client > side, through a form. Then, a simple line of code: > > form_dict = cgi.FieldStorage() > > grabs all data into a dictionary form_dict. The rest becomes a piece > of cake by querying the form_dict. Nice! >

Re: Define a constant in Python C extension

2009-02-27 Thread Stefan Behnel
fredbasset1...@gmail.com wrote: > I'm writing a C extension for Python, is it possible to define > constants in the C code and have them visible from Python? Have you looked at Cython? It allows you to define e.g. enums as "public" and will generate the rest for you. http://cython.org Stefan --

<    5   6   7   8   9   10   11   12   13   14   >