On the subject of getting the example Python API code to run:
On Sunday, May 27, 2012 4:39:38 PM UTC-7, Tim Crews wrote:
>
> for xact in ledger.read_journal("ledger.dat").xacts(): # Note the ()
> after xacts
> for post in xact.posts(): # Note the () after posts
> print "Transferring %s to/from %s" % (post.amount, post.account)
>
>
> Reading my original post a day later, I see that it probably came across
as abrupt. I also posted without providing any context. I'm sorry about
that.
Anyway, I read the Boost::Python documents to figure out how to make an
iterator wrapper that is also a property. The example given at
http://www.boost.org/doc/libs/1_49_0/libs/python/doc/tutorial/doc/html/python/iterators.htmluses
a ".property" function for this purpose, but that doesn't compile.
So I tried ".add_property" instead, and this works. If you change
py_journal.cc to use .add_property for xacts, and change py_xact.cc to use
.add_property for posts, then the original Python sample code will run as
written.
I've been reviewing the entire Python API with an eye towards putting
together an equivalent RESTful web API (see other post), and in the process
I think I see a few other functions that might be more "Pythonic" if they
were exposed as read-only properties. I was planning to publish a summary
soon of the entire Python API, and I will note these.
Does anyone have an opinion about what form a Python API summary document
ought to take? I would be willing to add it to the docs or the wiki, or
just post it on the list. Or am I duplicating someone else's effort?
Tim Crews