[Edu-sig] Errors in Wikipedia entry for IronPython?

kirby urner kirby.urner at gmail.com
Sun May 7 03:39:00 CEST 2006


I have a problem with this example code:

from BookService import BookDictionary

booksWrittenByBookerPrizeWinners = []
for book in BookDictionary.GetAllBooks:
    if "Booker Prize" in book.Author.MajorAwards:
        booksWrittenByBookerPrizeWinners.append(book.Title)
booksWrittenByBookerPrizeWinners

First, the variable names seem intentionally ugly, but I'm not going
to worry about that.  What really bugs me is
BookDictionary.GetAllBooks without making it callable.  The prefixing
verb Get would imply a function, and Python distinguishes itself from
Ruby (per Martelli) by making a sharp distinction between a function
*named* and a function *called*.

Perhaps its just an unfortunate naming issue, i.e. GetAllBooks is
really to be thought of as an iterable, not a function call.  Under
the hood, there might be some property, i.e. if it has to consult a
database (whatever BookService does).  But in that case, I'd really
prefer a function with no arguments, a callable in other words.

Anyway, as you can see, I'm unhappy with this code.

Plus there's a clear typo in the next sentence:

"In this case, assume that the .NET framework implements a class,
BookDictionary, in a module called BookService, and publishes an
interface into which IronPython scripts can be sent and exectuted."

I've edited Wikipedia before, but hesitate to dive in on this one
without more seasoning (comments?).

Kirby


More information about the Edu-sig mailing list