QuickTopic (SM) free message boards QuickTopic (SM) free message boards
Skip to Messages
  Sign In to access your topic list  |New Topic |My Topics|Profile
Upgrade to Pro   Customize, show pictures, add an intro, and more:   QuickTopic Pro...and check out QuickThreadSM
Topic: general online.effbot.org discussion (december 2004)
Printer-Friendly Page
All messages            1-101 of 101        
About these ads
Who | When
Messagessort recent-top    (not accepting new messages)
 Person was signed in when posted  1
21-08-2003 11:05 UTC
Deleted by topic administrator 30-11-2003 22:17
Jarno Virtanen  2
21-08-2003 13:20 UTC
I was thinking of arranging something similar. It's just that I'm afraid such would attract masses of drooling idiots (you know, like me). Although sending mail isn't that hard for the majority of us, it still has that some kind of strange barrier.

Honestly, the biggest problem I see is that one has to track the discussion somehow, and that just adds to everything else.
I don't know.
Fredrik Lundh  3
21-08-2003 17:23 UTC
Honestly, the biggest problem I see is that one has to track the discussion somehow, and that just adds to everything else.

Agreed. But QuickTopic offers you do get notifications (and reply?) by mail. Doesn't seem to work right now, though (why am I not surprised?)
   4
21-08-2003 20:52 UTC
Deleted by topic administrator 31-08-2003 17:55
Michael Hudson  5
27-08-2003 12:19 UTC
I guess it depends on popularity, but IME most web forums and/or blog comments just fill up with idiocy. LWN reader comments and the evolution developers blog are two of the more depressing examples of this.
Jarek Zgoda  6
27-08-2003 14:45 UTC
While I generally agree to Michael's note on idiocy, I would put Slashdot comments over LWN comments on the scale.
Michael Hudson  7
28-08-2003 11:39 UTC
Oh, slashdot is OFF the scale :-)

The difference between LWN's and slashdot's comments is that I have known that 99.9% of comments on slashdot are pure bullshit for a good few years now, whereas I had hopes for LWN having worthwhile comments -- and it does, sometimes, they're just the minority. Like I said, "two of the more *depressing* examples".
   8
13-09-2003 23:55 UTC
Deleted by topic administrator 14-09-2003 11:56
Anonymous  9
14-09-2003 23:32 UTC
Why does PyPI have a new, 1.2a4 release of elementtree listed when there is no such download on effbot.org?
Fredrik LundhPerson was signed in when posted  10
15-09-2003 07:03 UTC
Pilot error. I've updated the PyPI index. Thanks /F
Ramon Felciano  11
21-10-2003 20:53 UTC
Not sure if this is the right place to post this, but I have a feature request for ElementTree. I'd like to be able to delete node attributes, for example to strip out the bas attribute in:

<foo bar="hello" baz="bye"></foo>

AFAIK there is no way to do that with ElementTree: you can retrieve a list of node attribute names (keys()) but there is no method to remove elements from the attrib variable. Given that none of the methods include the name "attrib" I'm assuming that we shouldn't muck w that variable itself -- maybe I'm wrong here?

Thanks!
Fredrik LundhPerson was signed in when posted  12
22-10-2003 21:19 UTC
Accessing attributes through the attrib member is perfectly okay; as mentioned in the documentation, it's a real mutable dictionary.
Ramon Felciano  13
23-10-2003 04:04 UTC
Heh. I looked at the source code docs but not the web docs :-P Thanks for the clarification!
Rich Salz  14
22-11-2003 01:42 UTC
Using "this" as the namespace prefix for SOAP messages
is brilliant.
   15
24-11-2003 11:41 UTC
Deleted by topic administrator 24-11-2003 12:00
Adolfo  16
25-11-2003 05:29 UTC

Hello:

I am a Python newbie working on W2000 with Python 2.3.2 - I have RH9.0. but not stable yet.

* Any help will be much appreciated *

I started FL's Tkinter tutorial but got stuck on second sample "hello again". Here's the code and compiler complaints:

=========================================
from Tkinter import *

class App:

   def_init_(self, master):

frame = Frame(master)
frame.pack()adolfo@linuxmail.org


self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
self.button.pack(side=LEFT)

self.hi_there = Button(frame, text="Hello", command=self.say_hi)
self.hi_there.pack(side=LEFT)

def say_hi(self):
    print "Hi there, everyone !"

root = Tk()

app = App(root)

root.mainloop()


===========================================

ERRORS:

1. There is an error in your program, invalid sintax

 def_init_(self, master): (colon highlighted)

If I change the colon for ;

I get this:

Traceback (most recent call last):
  File "C:\Documents and Settings\Administrator\My Documents\11-PROJECTS\11-TKINTER-PROJECT\hello2.py", line 4, in ?
    class App:
  File "C:\Documents and Settings\Administrator\My Documents\11-PROJECTS\11-TKINTER-PROJECT\hello2.py", line 6, in App
    def_init_(self, master);
NameError: name 'def_init_' is not defined
>>>


========================================

Adolfo Aguirre
Santa Barbara, CA
Fredrik LundhPerson was signed in when posted  17
25-11-2003 14:32 UTC
Edited by author 26-11-2003 18:29
Please don't post long support questions in this forum; I prefer if use is limited to brief comments and questions regarding online.effbot.org postings. Also see:

http://www.pythonware.com/people/fredrik/busy.htm

As for your question, there are a few typos in your script, and the environment you used didn't point you in the right direction. Here's a copy of the original script:

http://www.effbot.org/zone/tkinter-hello-again.htm

Note that the __init__ line says (d) (e) (f) (space) (underscore) (underscore) init (underscore) (underscore) (paren) self, master (paren) (colon).
Fredrik LundhPerson was signed in when posted  18
06-12-2003 08:50 UTC
Note: www.effbot.org and online.effbot.org have moved to new servers. There's one known problem: access via effbot.org doesn't work properly at the moment; you have to add the "www" prefix to be able to access subpages. That should be fixed early next week.

Let me know if you find any other problems.

Cheers /F
infidel  19
09-12-2003 20:39 UTC
Edited by author 09-12-2003 20:41
I eagerly anticipate every new post at online.effbot.org.

I love what you've given us with the WCK. I wish Tkinter provided some sort of MDI Widget, or is there perhaps a better paradigm than MDI for multiple-windowed applications?

I took a stab at writing an MDI widget myself using WCK but got nowhere.

Edited to add: Oops, sorry if this wasn't the right forum to post in.
Aaron Brady  20
13-12-2003 18:50 UTC
I eagerly anticipate WinWCK being released, if that is, infact , your intention.

I looked at how effnews can handle drag'n'drop and has a lightweight windows interface, and would like to have a native interface without resorting to wxNamespacePollution.
Fredrik LundhPerson was signed in when posted  21
16-12-2003 20:35 UTC
Hmm. Looks like notification doesn't work. Let's hope the comment spammers won't notice.

Some brief answers:

WinWCK: it's likely that it will be released, but it's too early to say when. 2Q2004, perhaps?

MDI: I don't design MDI applications myself, so I haven't spent much time looking into that. The closest thing we've done uses a Canvas as a "custom window manager", but it's more Photoshop-like (views plus palettes) than Excel-like (multiple documents). If you need MDI for Tkinter, it could be worth asking for help over in Tcl/Tk-land. It's usually quite easy to wrap Tk code for use with Tkinter.
Tom H  22
17-05-2004 18:38 UTC
We needed to use XML-RPC on aan IIS server that uses NT Authentication. I found that by addint a new Transport class in xmlrpclib that uses Microsoft's XMLHTTP com object to connect everything works as desired. This code is kind of a hack job, but it works:


try:
  import win32com.client
except:
  pass

class TransportNTAuth:
    """Handles an HTTP transaction to an XML-RPC server.
       Uses Microsoft XMLHTTP to enable NT Authentication if the server requires it.
    """
    ##
    # Send a complete request, and parse the response.
    #
    # @param host Target host.
    # @param handler Target PRC handler.
    # @param request_body XML-RPC request body.
    # @param verbose Debugging flag.
    # @return Parsed response.

    def request(self, host, handler, request_body, verbose=0):
        # issue XML-RPC request

        if verbose:
          print '##########################'
          print host
          print handler
          print request_body
          print '##########################'

        try:
            httpObj = win32com.client.Dispatch(r'Microsoft.XMLHTTP')
        except:
            raise NotImplementedError(
                "Could not instantiate Microsoft.XMLHTTP"
                )

        try:
            httpObj.open("POST", "http://" + host + handler ,False)

            httpObj.setRequestHeader("Content-type", "text/xml")
            httpObj.send(request_body)
       
            r = httpObj.responseText

            if verbose:
              print '##########################'
              print r
              print '##########################'

            p, u = getparser()

            p.feed(r)
            p.close()
            return u.close()
        except:
            raise NotImplementedError(
                "WinHTTP proxy settings not set up or set up wrong. "
                 "See: http://support.microsoft.com/default.aspx?scid=kb;EN-US;291008"
                )
Danny  23
31-05-2004 12:51 UTC
I may be an arrogant shithead, but you don't need to put words into my mouth. I was only suggesting other things that could be done with the data.
Danny  24
31-05-2004 19:16 UTC
Brian M  25
01-06-2004 18:10 UTC
Thank you for elementtree. However, the new readme page
http://effbot.org/downloads/index.cgi/elem...20040531.zip/README
generates an error.
zgoda  26
15-06-2004 12:39 UTC
Strange characters (qmarks?) on online.effbot.org pages appear, because there's no character set declaration in head section of html documents. To be able to read your entries in Swedish, I must set ISO-8859-1 by hand in by browser (thanks God, it allows me to do that!). As your pages are generated (using some templating, I think), this should be not a big problem.
Fredrik LundhPerson was signed in when posted  27
18-06-2004 08:08 UTC
Edited by author 19-06-2004 11:43
Zgoda: Better now?

Brian: Better now? (the current README is here:
http://effbot.org/downloads/index.cgi/elem...20040618.zip/README )

Danny: If I'd meant to quote you specifically, I'd quoted you. Sure, your posts to Ted Leung's weblog probably qualifies you as an RDF shithead. But the problem isn't you; it's that you're *not* the only one.

As for RDF itself, I'll save that rant for another day.
Amanjit Gill  28
02-07-2004 12:09 UTC
Regarding Chandler .. I have to agree! They are not delivering anything useful (yet). I do not like their UI (yet). I do not think any outlook / whatever-PIM poweruser likes it.
Danny  29
02-07-2004 12:52 UTC
If your post wasn't directly specifically in response to my ill-considered post, then I really don't understand your animosity towards RDF developers. It's a technology that's great for solving a bunch of problems, a lot of the underlying theory is very interesting, and the Semantic Web vision seems to be the only broad but consistent future view around at the moment.

But it's just one technology amongst many. Most RDF fans aren't only into RDF. The stuff I'm working on at the moment includes most of the data in 'vanilla' XML formats, with some docs in HTML and integration stuff handled by RDF. Funnily enough, I normally code in Java but for this little sub-project I'm using Python.

Does this make me an HTML, XML, Java and Python shithead too?
infidel  30
02-08-2004 18:24 UTC
I'm having a hard time getting WCK installed with Python 2.4 on a Windows2000 system.

Here is the message I get:

*** cannot find Tcl/Tk headers and library files
    change the TCL_ROOT variable in the setup.py file

I tried examining the setup.py and setuplib.py files to see what the problem was. I can't find any tk.h file on my system, so apparently setuplib.py figures I don't have Tcl/Tk.

Any advice?

Thanks!
Fredrik Lundh  31
02-08-2004 19:06 UTC
well, if you don't have the Tcl/Tk build files, you cannot build the WCK driver from source.

You can get Tcl/Tk installers from www.tcl.tk (you probably need the ActiveTcl installers to get prebuilt lib files; make sure you get the same version as Python 2.4 was shipped with).

Alternatively, you could ask for help on the Tkinter-discuss list (http://mail.python.org/mailman/listinfo/tkinter-discuss); maybe someone has 2.4-compatible binaries to share. (I don't, at the moment).
KKZuberi  32
03-08-2004 18:04 UTC

Is this where we comment on your blog postings? Just wanted to mention some surprise at your dissatisfaction with the new '@decorator' syntax thingy, because apparently Guido mentioned your approval in defending it!
 http://mail.python.org/pipermail/python-de...-August/046704.html

Probably i'm not reading some part of the story correctly?
Fredrik LundhPerson was signed in when posted  33
03-08-2004 18:51 UTC
Edited by author 04-08-2004 11:23
"Fredrik Lundh even liked it"

Hmm. Weird. That's definitely not how I remember things. I guess I have to sort that out with Guido over a beer, some day ;-)

Guido's EuroPython keynote was something of a disappointment; he wasn't his usual self (he didn't feel well enough to go to the conference dinner later that night), and most of the time was spent on a lets-hear-what-the-peanut-gallery-has-to-say discussion about decorators.
 
After the keynote, I felt quite confident that Guido would do the right thing: either go for his favourite (C#-style [] on a line before the def), or forget about the whole thing for 2.4.

We did talk about it briefly after the keynote (or maybe it was the day after), but IIRC, that discussion was mostly concerned with why the "decorators at the same line as the def-statement" alternatives were inferior, and how typical it is that everyone has opinions about syntax issues, but nobody ever asks obvious questions about the semantics.

(in this case, the obvious question is "if there are multiple decorators, in what order are they applied?" When I asked that question on the EuroPython conference dinner, half the people at my table said "that's obvious, from right to left" and the other half said "that's obvious, from left to right")

But alright, I might have said something along the lines of "I trust you to do the right thing" at a time when he had already changed his mind...

(update: I just checked with another person who was there, and all he remembers is the "same line or not" part of the discussion.)

Anyway, I don't care much about the syntax; it's the process that worries me. If Guido doesn't like something, it shouldn't be in the core language.
Mark Russell  34
03-08-2004 19:41 UTC
Edited by author 03-08-2004 19:42
"...so someone I've never heard of added a major syntactic feature to Python 2.4, using a syntax that Guido doesn't really like"

You make it sound like I forced something into python against Guido's wishes. Guido asked for an implementation of the @decorator syntax. I implemented exactly what he requested.

This is Guido's design - my only input was the time to do the implementation. And I think people should do exactly what you say: trust his intuition on language design.
Fredrik LundhPerson was signed in when posted  35
03-08-2004 20:24 UTC
Edited by author 04-08-2004 09:43
No, it's not Guido's design. It was one of many proposals, and it sure wasn't his favourite when he went to the EuroPython keynote. See page 14 ("and the finalists are") and 15 ("I still like this one best") in his slides if you don't believe that.

In the post KKZuberi links to, Guido says he changed his mind based on input at the conference, but I suspect that he simply gave up arguing for his favourite solution. Let the loudmouths have their way; people don't use decorators much anyway (if you think you need to make something a class method or static method, you're probably wrong), so why waste more energy on this?

And that's what worries me -- and many others.
Mark Russell  36
04-08-2004 09:31 UTC
Sorry, I was unclear. I should have said that this is Guido's current preferred design. That's good enough for me.
Fredrik LundhPerson was signed in when posted  37
04-08-2004 10:15 UTC
So the fact that this is a complete process breakdown doesn't worry you? Or does process only apply to others? (when I post this, the PEP doesn't even mention the syntax you implemented).
Ian Bicking  38
04-08-2004 15:55 UTC
Re: string searches.

Common prefixes seem like a relatively common occurance, though it would be interesting to actually run a very significant program (e.g., Zope), and record all the comparisons that are done. If, statistically, it is common to search for something where the first 3 or 4 characters are common, but the search string starts to become more unique after that, maybe instead of checking just the first character it would make sense to check the first character and the last character. The last character will have to be checked eventually, after all.

It seems kind of cheap, but it would mean the comparison 'not there' in 'not the xyz'*100 would only require 200 character comparisons, as compared to the current situation where (I imagine) it requires 1000 character comparisons and 100 memcmp operations, and each memcmp compares 8 characters.

Wait, no, that's not right. That's where those overlap tables come into play. If you check the last letter, you still have to look for each n, so that's 1200 character comparisons.

How much faster is memcmp compared to character-by-character comparisons? If character-by-character were okay, you could do the benchmark in 1100 comparisons, by simultaneously looking for a match after you find the 'n', but also looking for the next 'n' (which you would skip back to if the match fails). If memcmp is a lot faster than character-by-character comparisons, then this would slow down the case where the search string was relatively large compared to its position in the text being searched. But I think search strings are usually fairly small, and a failing search is quite common.

Maybe you've already thought about these ideas, but it seems interesting. An empirically determined set of searches for benchmarking would probably be very useful, as there's a lot of potential tradeoffs.
Mark Russell  39
04-08-2004 15:59 UTC
If it's process versus Guido, I'll put my money on Guido every time. I put a lot of trust in Guido's considered judgement, based on his track record so far. If I thought he was putting this in against his better judgement then I would worry, but I don't think that's the case (based again only on track record - I've never met him).
Fredrik LundhPerson was signed in when posted  40
04-08-2004 16:47 UTC
The process is there to handle things when (loud portions of the) community refuses to trust Guido's intuition. Did you support his original ideas, or do you trust him only when he does what you want?
Fredrik LundhPerson was signed in when posted  41
04-08-2004 17:13 UTC
Re: string searches

Instrumenting an interpreter is a good idea. Just wish I had time to work on this...

(I'm beginning to suspect that a simple "unused character" bitmap could help a lot; it doesn't take long to set up, and if combined with the "check last first" approach, it's likely to save lots of false memcmp's for the common case you mention: small search strings, failing searches.)
Mark Russell  42
04-08-2004 17:47 UTC
Edited by author 04-08-2004 17:49
I trust him to arrive at the right decision. Sometimes that involves going along with community input (e.g. dropping the "[decorator] def" idea), sometimes it involves making a BDFL pronouncement (part of the process, no?) to end a discussion which is going nowhere.

For the record (not that it matters much - I have no influence over the final decision whatever it is) I originally thought "def foo() [decorators]" was the obvious answer. "[decorators] def foo()" looked quite nice until the ambiguity problems surfaced. My initial reaction to @decorator was "yuck", but then I tried using it for a bit and it became obvious that it had lots of nice properties.

I do discount lots of the dissenters, for various reasons:

      - I'm sure most of them haven't tried using the
        syntax

      - They don't have a track record in language design

      - They were proposing hacky and ugly alternatives

      - *Any* syntax proposal generates lots of noise.
        It's very easy to have an immediate gut reaction
        to new syntax, based largely I suspect on the
        fact that it is new. Example: the usual initial
        reaction to python's braceless syntax is "yuck",
        which changes 180 degress with about half a day's
        use.

Anyway, I think I've gone on long enough :-)
Anthony Baxter  43
04-08-2004 18:57 UTC
For what it's worth, Guido came up with the @syntax, no-one else did. The first mention I have of it is in a private email I sent his to enquire about what the state of the decorator decision was, some time after a1, and before a2.

Mark Russell did an implementation (after Guido requested that someone do this, because he had no time to do it himself), and I did the checkin (again, after Guido requested it, after he said he was happy with it).

I'm not sure exactly how this could be construed as not being Guido's decision.
Fredrik LundhPerson was signed in when posted  44
04-08-2004 19:18 UTC
Edited by author 04-08-2004 19:29
Really? When I talked to him at EuroPython, I'm pretty sure he said that someone else had proposed it
(it's taken from Java/JavaDoc, or maybe from PythonDoc ;-).

Our discussion is referred to in this post (two weeks after the conference), where Guido still mentions that C# is his favourite, but pretty much leaves it to python-dev to make the final decision... and so you did.
Anthony Baxter  45
04-08-2004 20:31 UTC
Well, the first I heard of it was from him, when I prodded him to ask if he'd made a decision (some time after a1 was out).
Anthony Baxter  46
04-08-2004 20:38 UTC
and one final point - I made *no* decisions here. The decision was from Guido.
Michael HudsonPerson was signed in when posted  47
05-08-2004 11:31 UTC
Re searching, I bet there's some way to lazily construct the KMP tables when you need them rather than upfront. But then I don't really know anything about this topic :-)
Fredrik LundhPerson was signed in when posted  48
05-08-2004 18:42 UTC
Edited by author 05-08-2004 22:08
Judging from what Google brought up, there are ways to create the KMP data as you go, but they all seem to involve intricate data structures (or at least real functional languages). I'm pretty sure a single malloc/free pair in find would kill performance for a majority of all common cases, so I'm going to avoid that kind of algorithms for as long as I possibly can.

However, I have played a bit with the idea I mentioned earlier, and have an algorithm that has a relatively small setup overhead and needs only two registers to hold all information (unlike KMP that needs one register per character in the search string, or Boyer-Moore that needs one register per character in the search string character set! that is, a million registers for Unicode...).

For Jim's test case, it needs ~200 comparisions in total, compared to ~1100 comparisions and ~100 memcmp's for the current algorithm (a total of 1100+8*100=1900 comparisions, plus memcmp setup overhead).

More later, if/when I manage to write a C version of my test program.

(update: I found a search simulator applet, and ran Jim's test on that. According to the simulator, BM needs ~300 comparisions on this test case. KMP needs ~1100 in total)
Michael HudsonPerson was signed in when posted  49
06-08-2004 10:04 UTC
Oh sure, all these things come at the price of complexity :-)

Big-O behaviour isn't very relavent when m and n are both about 10.

Good luck with your experiment!
Jerry Gamache  50
10-08-2004 15:18 UTC
REPE COMPSB is inefficient at comparing small strings, and has a long setup penalty. See section 18.1 of the Pentium optimization guide at:
http://www.agner.org/assem/
The i686 optimized assembly version of strcmp in the GNU libc does not use REPE anymore.
Win Carus  51
13-08-2004 12:33 UTC
With reference your request for further information about the relationship between the Horspool and Sunday variants of the Boyer-Moore string matching algorith:

The Sunday work was clearly done later (about a decade) and is clearly inspired by Horspool (and many more approaches, apparently). Here's a quick chronology of the relevant papers:

1. R.S. Boyer and J.S. Moore. A fast string searching algorithm. Comm. ACM, 20:762--772, 1977.

2. R. N. Horspool, `Practical fast searching in strings', Software---Practice and Experience, 10, 501--506 (1980).

3. D. Sunday. A very fast substring search algorithm. Communications of the ACM, 33(8):132-142, August 1990.

4. A. Hume, S. Sunday. Fast string searching. Soft.-Prac. and Exp. 21 (November 1991), 1221--1248.

If you subscribe to the ACM archives, you can download the original ACM paper (#3) in PDF:

http://portal.acm.org/citation.cfm?id=79184&dl=ACM&coll=portal

For a much more detailed paper in a larger historical context, you can download the freely available Hume/Sunday paper (#4) from CiteSeer in a variety of formats:

http://citeseer.ist.psu.edu/hume91fast.html

This paper presents a taxonomy of string-search algorithms and shows the relationships among a wide range of algorithms. From an implementation and practical-user point of view, #4 is much more helpful than #3, in any case. C source code is also provided for SUnday/Hume's recommended algorithms.
Gordon Tyler  52
16-08-2004 00:12 UTC
With regards to Subversion and maintaining master and work repositories:

While I'm no Subversion expert, I think you might want to look into the use of the "svnadmin dump --incremental" command. See the Subversion book's section on Migrating repositories: http://svnbook.red-bean.com/svnbook/book.html#svn-ch-5-sect-3.5

The caveat with the above is that you'd have to perform filtering on the dump output to finagle the working repo paths into the master repo paths. The Subversion book's section on svndumpfilter might help: http://svnbook.red-bean.com/svnbook/book.html#svn-ch-5-sect-3.1.3
Hernan Foffani  53
19-08-2004 10:53 UTC
About Subversion mirroring.
Did you see SVN::Mirror (also called svm)?
In their terms your master repository would be the mirror.

Considering your detailed constraint list you may already tried it. Sorry if that's the case.

-H.
Richard Jones  54
20-08-2004 22:42 UTC
Re: elementtree

I wonder what the guys implementing the "std" library replacement are using?

Can't find any actual web references except a talk at EuroPython...
André  55
23-08-2004 05:35 UTC
Apropos your benchmarking of August 20.

Could you please try the pyrxp library as well?
It's a tree-bulding XML toolkit as well and I've always been pleased with the speed of it.
Fredrik LundhPerson was signed in when posted  56
23-08-2004 09:41 UTC
As has been noted before, pyRXP doesn't really support XML:

pyRXP.Error: Error: 0x2014 is not a valid 8-bit XML character
in unnamed entity at line 19 char 43 of [unknown]
0x2014 is not a valid 8-bit XML character
Parse Failed!


Using pyRXPU instead, I get 0.24 seconds and 11 MB memory. Not bad at all.

(but note that my point wasn't that some toolkits are really fast; it was that some toolkits are remarkably slow)
Michael Hudson  57
23-08-2004 12:06 UTC
Also ignoring your point, I'm interested to notice that minidom is four times faster in 2.3 than 2.1...
Fredrik LundhPerson was signed in when posted  58
23-08-2004 12:46 UTC
Edited by author 23-08-2004 16:27
Yup. But the ElementTree timings are pretty much identical, so it's not a general Python speedup. From a quick look, they seem to be using a new custom DOM builder, combined with new expat features. Hmm. I think I have look into this for ElementTree 1.3...

(a five second hack indicates that I can shave off about 0.5 seconds from the elementtree timings, on Python 2.3 and newer. It's always easier to speed things up when you control all modules involved ;-)
Donald Yohe  59
23-08-2004 21:35 UTC
Good evening Fredrik,
I bought the "Python Standard Library" book at Barnes & Nobel. I must drop each example into windows wordpad, select all, copy and save using notepad to get usable code. Please allow access to the html zip version of the book so I can copy and paste the exaples in windows. The pdf format left justifies everything.

Thanks, and Cheers,
dcyohe@verizon.net
André  60
24-08-2004 08:47 UTC
Thanks for the updated benchmark. I did not know that pyRXP was non-conforming, so I appreciate the link.
David Mertz  61
24-08-2004 15:56 UTC
Hi Fred,

I wonder if you might try my gnosis.xml.objectify library in your roundup of XML tree API benchmarks. I did something along those lines in my ElementTree article at http://www-106.ibm.com/developerworks/library/x-matters28/.

But it's hard to get an accurate sense of the relative speed and memory based on a different machine, different data set, different Python version, etc. Actually, I believe gnosis.xml.objectify has also been enhanced since then also. Gnosis used to lose some structural information on parsing (by design), I added that lost information back in for the occassional users who want it. But adding more probably slows things down slightly, and probably uses slightly more memory. I think it probably still comes in close to ElementTree though.

Latest library at http://gnosis.cx/download/Gnosis_Utils-1.1.1.tar.gz
Fredrik LundhPerson was signed in when posted  62
24-08-2004 20:27 UTC
I'll add xml.objectify to my todo list, together with libxml and cdomlette.

(My guess is that libxml is somewhere between pyrxpu and elementtree/sgmlop, cdomlette is somewhere between elementtree/sgmlop and elementtree, and that objectify is slightly slower than elementtree. Let's see if I can prove myself wrong ;-)
infidel  63
24-08-2004 21:34 UTC
As a closet advocate of Python I'm not sure what to make of the decorator debate. For what it's worth (not much, I reckon), I like this syntax:


def foo(bar):
    __decorator__ = [staticmethod, returns(int)]
    pass


Looks a lot like the __metaclass__ syntax (not that I understand metaclasses well) so seems very pythonic to me, has no perlish characters, and is close enough to the object declaration to be easily visible.

IMO, of course.
Robert Brewer  64
24-08-2004 23:59 UTC
I'd appreciate a less-obscure comment about the alternative decorator proposal, if you could manage it. Or are you just bookmarking it for your memoirs?
infidel  65
25-08-2004 15:21 UTC
I'll say that your "optimal decorator syntax" looks nicer than most alternatives I've seen, but I wouldn't call it "optimal" myself. Something about it doesn't feel right to me.

I understand the objection to "inside def" proposals, but at the same time I don't see why an "inside def" syntax need be rejected wholesale.

Isn't:


def foo(bar):
    pass


basically a shorthand for:


class foo(object):
    def __call__(self, bar):
        pass


?

Conceptually, at least? If I'm not way off base here then I don't see why __decorator__ or __features__ or __using__ can't be made a special attribute of a def block that is executed at def-time rather than call-time. At least it looks nicer (to me, anyways) than the pie symbol.
Fredrik LundhPerson was signed in when posted  66
27-08-2004 08:09 UTC
Edited by author 27-08-2004 08:09
Robert, no offense, but the combination of arrogance, pompousness, and sloppy thinking in that piece is quite remarkable.

I especially like the way you start out by arguing that it's a good thing to make decorators look *exactly* like existing *Python* constructs with entirely *different* semantics, and then you argue that Python decorators should *not* look like constructs with very *similar* semantics from *other* languages -- and to top it off, you pick a keyword from C# that means something entirely different.

There's no fucking way your proposal follows from your analysis; you just made all the arguments up afterwards.

I'd say it's 7 of 10 on my crackpot scale.
infidel  67
27-08-2004 13:52 UTC
'A' for effort, though. LOL.
Robert Brewer  68
30-08-2004 17:45 UTC
None taken; I appreciate your reply. More important to me than getting J2 over A1 is to get the debate focused down to one alternative and pronounced upon, so we and especially Guido can move on.

Regarding "similarities and differences", that's an issue which is far too subjective, IMO. It's a shame it had to be addressed at all, but there were SO MANY people arguing those issues (on both sides) that I felt it had to be included. Odd that you assumed we picked "using" from C#, for example--that connotation never came up while writing and rewriting the draft, and is completely irrelevant. The same could be said for your post on clp about function invocation as an example of "bare expressions"--if I'd come across it last week, I would've tried to address it, and probably would've changed the stance of the proposal somewhat. But time was just too short.

"There's no fucking way your proposal follows from your analysis; you just made all the arguments up afterwards."

Absolutely; I'm as human as the next guy--that's the way brains (and therefore analysis) work most of the time. That goes double when you're trying to speak for a community who doesn't know why they believe what they do. I tried to discover what they believe and analyze why, not pick a syntax out of the blue. Although I wrote it in biased tones, I won't be a bit sad if Guido rejects it. Sorry the advocacy came across as arrogance.
Kevin Cazabon  69
04-09-2004 20:29 UTC
Hey Fredrik;

Although I agree that the attention paid to the Russian school attack is not at the level it should be (it scares the HELL out of me... having a little boy myself now), to be fair to CNN.com they've had it as the major story 50-60% of the time over the last few days.

It should be 100%, but it's also not just a "little link".

Semantics though... I still don't trust CNN to be neutral and impartial, nor complete. They've got as much of a political agenda as Al Jazera (sp?).

Kevin.
Fredrik LundhPerson was signed in when posted  70
05-09-2004 18:43 UTC
Kevin, what puzzled me was that none of the US blogs I read has mentioned this, at all. Not even the "political blogs", nor the ones that use to cover international terrorism. And when I checked US media on friday afternoon and yesterday, everyone was busy with Clinton's bypass, and yet another hurricane. As were the bloggers. I don't really know what to make of this, but I do find it a bit disturbing.
Kevin Cazabon  71
05-09-2004 19:30 UTC
I guess living in Europe now I get a lot more European news. I'm amazed that with Sept. 11 still in everyone's minds (this week is the anniversary after all) that terrorism like this would take second rate to a hurricane. I personally think it's as significant as Sept. 11, and even sadder due to them TARGETING kids.

Especially with the "potential" link to Al Queda (that doesn't look right...), you'd think they'd be all over that.

Personally, I couldn't care less about Clinton's bypass, the upcoming elections, and whatnot (being a Canadian that's easy to say though), but my heart sank following the Russia tragedy (I spent a little too much time at work trying to keep up with events on it).

One thing that's tough to get though is ANY news about Canada. :)

Kevin.
Phil  72
13-09-2004 11:04 UTC
OS X 10.2.8

bash-2.05a$ uname -a
Darwin TheComputer.local. 6.8 Darwin Kernel Version 6.8: Wed Sep 10 15:20:55 PDT 2003; root:xnu/xnu-344.49.obj~2/RELEASE_PPC Power Macintosh powerpc

--------------------------------------------------------------------
PIL 1.1.5a4 BUILD SUMMARY
--------------------------------------------------------------------
version 1.1.5a4
platform darwin 2.3 (#2, Jul 30 2003, 11:45:28)
              [GCC 3.1 20020420 (prerelease)]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE support ok

*** Warning: zlib 1.1.3 may contain a security vulnerability.
*** Consider upgrading to zlib 1.1.4 or newer.
*** See: http://www.gzip.org/zlib/advisory-2002-03-11.txt
--------------------------------------------------------------------

bash-2.05a$ python2.3 selftest.py
*** The _imaging C module is not installed

 * Needed to add library path for fink freetype to `setup.py`.

  * Found FAQ re: error message on your site, but hit self-imposed time-limit, sorry... :-)
selasley  73
13-09-2004 14:13 UTC
Darwin Scotts-Mac.local 7.5.0 Darwin Kernel Version 7.5.0: Thu Aug 5 19:26:16 PDT 2004; root:xnu/xnu-517.7.21.obj~3/RELEASE_PPC Power Macintosh powerpc

[~/Desktop/Imaging-1.1.5a4] sel% python
Python 2.3.4 (#1, Jun 12 2004, 13:49:49)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1640)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D

[~/Desktop/Imaging-1.1.5a4] sel% python setup.py build_ext -i
...
--------------------------------------------------------------------
PIL 1.1.5a4 BUILD SUMMARY
--------------------------------------------------------------------
version 1.1.5a4
platform darwin 2.3.4 (#1, Jun 12 2004, 13:49:49)
              [GCC 3.3 20030304 (Apple Computer, Inc. build 1640)]
--------------------------------------------------------------------
*** TKINTER support not available (Tcl/Tk 8.4 libraries needed)
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE support ok
--------------------------------------------------------------------

[~/Desktop/Imaging-1.1.5a4] sel% python selftest.py
55 tests passed.

Notes: libjpeg, etc installed with iInstaller, not fink. OS X python 2.3 was replaced with version 2.3.4, Tcl/Tk Aqua 8.4.7 installed
infidel  74
13-09-2004 17:48 UTC
I'm not at all surprised at the lack of US media attention given to the Russian school tragedy. When the evening news devotes many minutes of airtime to cheesy animations about Jennifer Lopez and Ben Affleck or the latest Brittney Spears "controversy" then one can only assume that some preponderance of viewers actually cares about such garbage. It's hard to see someone who cares enough about Brittney and J.Lo. to want them in the evening news caring about anything in Russia. As if these people could even find Russia on a map.

Covering the weather is easy. Covering real news is harder and riskier.
Brian  75
13-09-2004 20:09 UTC
uname -a
Darwin brianl.local 7.5.0 Darwin Kernel Version 7.5.0: Thu Aug 5 19:26:16 PDT 2004; root:xnu/xnu-517.7.21.obj~3/RELEASE_PPC Power Macintosh powerpc

python
Python 2.4a3 (#6, Sep 7 2004, 17:36:39)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin

setup.py:
FREETYPE_ROOT = ("/sw/lib", "/sw/lib/freetype2/include")

python setup.py build_ext -i
running build_ext
--- using frameworks at /Library/Frameworks
---------------------------------------------------------
PIL 1.1.5a4 BUILD SUMMARY
---------------------------------------------------------
version 1.1.5a4
platform darwin 2.4a3 (#6, Sep 7 2004, 17:36:39)
              [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)]
---------------------------------------------------------
--- TKINTER support ok
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE support ok
---------------------------------------------------------

python selftest.py
55 tests passed.

I'm using a framework build of TCL/TK 8.4.7
ls -d /Library/Frameworks/T*
/Library/Frameworks/Tcl.framework
/Library/Frameworks/Tk.framework
The Badger  76
16-09-2004 09:52 UTC
Re: argh

Nice to see that the Subversion people managed to reproduce CVS's quirks, too.
Fredrik LundhPerson was signed in when posted  77
16-09-2004 10:02 UTC
Yup. Just wish it hadn't taken me ten minutes to realize what was going on...

$ rm -rf font/.svn
$ svn add font
Stewart Midwinter  78
27-09-2004 19:45 UTC
re: September 20, 2004
Tkinter Tricks: Using Complex Numbers to Rotate Canvas Items

Just read the bit on using complex numbers for Tkinter canvas coordinates: good trick! Code sample wouldn't run for me, choking on the following line:
    c.coords(polygon_item, *newxy)
My default version of Python is 1.52 (my employer still uses this old version for a number of reasons), so I switched to Python 2.3.4 and the code ran fine.

Thanks again for the tip.
Fredrik LundhPerson was signed in when posted  79
27-09-2004 20:10 UTC
Edited by author 27-09-2004 20:10
The f(*args) syntax was added in Python 2.0. For older versions, you can use apply(f, args) instead. In this case, you'd have to write:

    apply(c.coords, (polygon_item,) + tuple(newxy))
Stewart Midwinter  80
06-10-2004 21:21 UTC
ElementTree needs Python >v.2.0?

I downloaded and tested ElementTree and found it a useful way to simplify my parsing of an xml file. Then I tried it with Python 1.5.2 and it complained that it couldn't find module expat in xml.parsers. I take it this means that I need a higher version of Python? Is there still a version of ElementTree that will work with good ol' 1.5.2? (yes, I know all of the benefits of 2.3.4, but my employer is using a customized version of 1.5.2 so I can't upgrade right now.
Fredrik LundhPerson was signed in when posted  81
07-10-2004 06:43 UTC
Quoting the README:

The modules are designed to work with Python 2.1 and newer. The core ElementTree module and the SimpleXMLTreeBuilder class also works under 1.5.2 and 2.0. /.../

Usage:

    import ElementTree, SimpleXMLTreeBuilder
    parser = SimpleXMLTreeBuilder.TreeBuilder()
    tree = ElementTree.parse("sample.xml", parser)

Note that xmllib doesn't always handle namespaces properly; see the notes in the README file for details.

Hope this helps!
Stewart MidwinterPerson was signed in when posted  82
07-10-2004 16:52 UTC
re: ElementTree under Python 1.5.2

Following your advice, I made a slight modification to my code and now have it working under Python 1.5.2. The only catch was that for some reason, Python 1.5.2 could not find the SimpleXMLTreeBuilder module, even though it was installed with ElementTree in the ..\Python\elementtree folder; only after I copied it to my data-file directory did my script work.

code under Python 2.3.4:
from elementtree.ElementTree import ElementTree
root = ElementTree(file="sample.xml")
...

code under Python 1.5.2:
import ElementTree
import SimpleXMLTreeBuilder
parser = SimpleXMLTreeBuilder.TreeBuilder()
tree = ElementTree.parse("sample.xml", parser)
root = tree.getroot()
...
midtoadPerson was signed in when posted  83
09-10-2004 17:59 UTC
this note is for other beginner users of ElementTree.

Here's how to parse a simple XML file with attributes in it, add an item to the tree, then delete an item. At this point, one unresolved issue is how to have the xml encoding added to the top of the output file.

#et1.py
from elementtree import ElementTree
import os

'''our input file population2.xml looks like this:
<?xml version='1.0' encoding='utf-8'?>
<population>
<person name="joe" sex="male" age="49"></person>
<person name="hilda" sex="female" age="33"></person>
<person name="bartholomew" sex="male" age="17"></person>
</population>
'''

os.chdir("d:\\data\\python\\effbot")
tree = ElementTree.parse("population2.xml")
root = tree.getroot()

# display entire tree in standard output
ElementTree.dump(root)

print ''

# add an element
elem = ElementTree.Element("population")
newelem = ElementTree.SubElement(elem, "person", name="Fred", sex="male", age="47")
root.append(newelem)
ElementTree.dump(root)
print ''

# delete an element
for it in tree.findall("person"):
   if it.attrib["name"] == "joe":
     print "I found Joe!"
     root.remove(it)
     break
else:
   raise AssertionError("Where's joe?")

ElementTree.dump(root)
print ''

tree.write("outfile.xml")


---
cheers
Stewart Midwinter
Fredrik LundhPerson was signed in when posted  84
09-10-2004 18:13 UTC
"one unresolved issue is how to have the xml encoding added to the top of the output file"

By default, the element writer omits the XML header and uses ASCII as the encoding (an XML parser will treat this as a UTF-8 document, which is ASCII-compatible). To specify another encoding, pass the encoding keyword argument to the write method:

tree.write("outfile.xml", encoding="iso-8859-1")

Note that the writer uses character references for characters that cannot be represented in the given encoding, so you don't really have to bother with encodings.
Exemaker won't work  85
10-10-2004 18:19 UTC
Traceback (most recent call last):
  File "c:\pl\python23\exemaker.py", line 2, in ?
    import site
ImportError: No module named site
Fredrik LundhPerson was signed in when posted  86
10-10-2004 18:25 UTC
Edited by author 10-10-2004 22:20
Can you start python itself from the command line? What are sys.prefix and sys.executable set to? Nevermind. There seems to be an issue with exemaker and Python 2.3, at least when the Python DLL is installed in the Windows system32 directory. Stay tuned.

I just posted a 1.1 release, which should fix this problem.
midtoadPerson was signed in when posted  87
10-10-2004 23:15 UTC
re exemaker and site:

Indeed, your latest version, dated today, Works For Me (c) under Python 2.3. Handy utility, by the way!

thanks
Stewart Midwinter
Fredrik Nehr  88
29-10-2004 12:00 UTC
Hi Fredrik,

You have tried Keyhole (www.keyhole.com), right!? Cool application.

/Fredrik
Andrew Dalke  89
07-11-2004 16:08 UTC
It isn't quite fair to compare the 1st stage Saturn V with the thrust of SMART-1 itself. The latter was boosted into Earth orbit with a Ariane 5 rocket which has a thrust of 745 tons (115 from the main engine and 630 from the boosters, says http://www.esa.int/SPECIALS/Launchers_Acce.../ASEVLU0TCNC_0.html ) or 7.6 MN. That's about 1/5 of the Saturn V.
Fredrik LundhPerson was signed in when posted  90
07-11-2004 17:24 UTC
Yeah, that wasn't a very serious comparision (and I have to admit that I didn't remember that Apollo did in fact spend a couple of hours in an ordinary Earth orbit; the Saturn engines only contributed to the first leg of the trip).

But I did leave out the part about getting to the moon in 72 milliseconds ;-)

On the other hand, the Apollo engine used to leave the Earth orbit had a thrust of 890 kN. That's 500,000,000 times more than SMART-1, for the orbit-to-orbit part.
andres  91
09-11-2004 01:42 UTC
WOW , absolutly no link to contact Fredrik , hehe.

Well i just want to point that searching in the python package index www.python.org/pypi for the "xml" term gives no results related to element tree, so people who doesnt know about it cant find it, so it would be nice if the word "xml" is added in the description
Andrew Dalke  92
09-11-2004 04:40 UTC
Inga problem, /F. For another neat trip using low power (though chemical, not ion), see http://www.sp.ph.ic.ac.uk/~balogh/isee3.htm . ISEE 3/ICE took 1.5 years and 5 lunar flyby gravity assists to get to Comet Giacobini-Zinner from L2.
Fredrik LundhPerson was signed in when posted  93
10-11-2004 16:50 UTC
I've re-registered the 1.2.1 release, with a better "long description" (for some reason, "search description" doesn't look in the "description" field from the setup file...)

As for the mail address, the first google hit for "what's fredrik lundh's mail address" does indeed bring you do a page with David Mertz mail address, but my mail address isn't really that hard to find (which probably explains the 1000+ spams I get each day). Did you look in the elementtree readme, for example?
Vinj  94
10-11-2004 23:00 UTC
I'm using elementtree to create xml files to be read by excel. Excel uses the following for a lot of their attributes:

<cell ss:Type="Number">
<Worksheet ss:Name="worksheet1">

I get the following error when I do the following:
a = Element("workshee", ss:Name="worksheet1")

this is expected since : is reserved by python. Is there a workaround?
Fredrik LundhPerson was signed in when posted  95
11-11-2004 07:19 UTC
If you look at the top of the excel document, you'll notice a xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet attribute. This means that "ss" is a namespace, and that a tag that is named e.g. ss:Name is in fact a "Name" tag that lives in the "urn:schemas-microsoft-com:office:spreadsheet" namespace.

For more information on namespaces in ElementTree, see http://effbot.org/zone/element.htm#xml-namespaces

For more information on namespaces themselves, see http://www.jclark.com/xml/xmlns.htm
Darran  96
14-11-2004 00:57 UTC

Could we possibly get formatted xml output (a la
"xmllint --format") added to ElementTree? Possibly
just ElementTree.write("test.xml",formatted=1).
Unless an equivalent already exists and I'm missing
it somehow ...
Daniel Biddle  97
25-11-2004 01:47 UTC
The links in the RSS feed don't work for me: I get error messages about bad URL syntax, and they seem to be missing a pathname.

Example: http://online.effbot.org#20041124
Fredrik LundhPerson was signed in when posted  98
25-11-2004 06:38 UTC
Get error messages from where? "http://online.effbot.org" is the URL itself; "#20041124" is a fragment identifier. It's a perfectly valid URL.
Michael HudsonPerson was signed in when posted  99
25-11-2004 13:14 UTC
Oh well.

Results 1 - 10 of about 260,000 for "py line *".

Both this and the pm one include a fair few "false positives" -- people talking about error messages, and just random stuff like "Form 1-NR/PY, line 12".
Daniel Biddle  100
26-11-2004 05:58 UTC
The "Bad URL syntax" error is from my browser, but it's dumb enough to think it should add a slash to the end of the fragment identifier, so there's definitely a browser bug or two. Sorry to bother you about that.

I still think the link URI for each item should be a permalink; the guid element has a suitable URI.
Fredrik Lundh  101
07-12-2004 20:33 UTC
RSS link What's this?
All messages            1-101 of 101        
QuickTopicSM message boards
Over 200,000 topics served
Learn more Frequently asked questions  Acknowledgements
What they're saying about QuickTopic
 Questions, comments, or suggestions? Contact Us
Read our use policy before beginning. We value your privacy; please read our privacy statement.
Copyright ©1999-2008 Internicity Inc. All rights reserved.