Thanks, John! Thanks, Marco.

So, trying to figure this out is stretching me as I'm not a full-time 
developer, but simply beginning with python, and I've never studied object 
oriented programming before (my coursework in university was all 
functional, in Ada95 and Fortran 77).

I'm building myself a script to calculate First In, First Out cost basis 
for commodities. I've used this (where query is a ledger query I'm passing 
to my script via the command line argv):

for post in ledger.read_journal(filename).query(query):

to isolate the transaction posts that augment and reduce my commodity lots.

I'd like to modify those posts by inserting the {price unit} [date] lots 
information, adding necessary postings if I have to reduce from multiple 
lots. Is there a command in the python bridge similar to the ledger print 
command, so that after I've manipulated the posts, I can print the output 
in ledger format to stout?

I might be in over my head, but figured I'd try.

Thanks in advance,

Joel


Le samedi 26 août 2017 10:51:13 UTC+2, Marco Bakera a écrit :
>
> Joel Swanson schrieb am 25.08.2017 um 13:56: 
> > 
> > | 
> >  importledger 
> >      for xact in ledger.read_journal("sample.dat").xacts(): 
> >          for post in xact.posts(): 
> >              print"Transferring %s to/from 
> %s"%(post.amount,post.account) 
> > | 
> > 
> > I'm able to assign post.amount and post.account to variables/lists in my 
> > python code. I discovered I can also use post.date for the date. 
> > 
> > I'm relatively new at python. Where can I find a list of what other 
> > options are available in the 'post' object? Is this something I can find 
> > somewhere in Ledger's source code? 
>
> When you run the code above you can use 'dir(post)' or 'dir(xact)' to 
> get the properties and methods of the object. 
>
>
>
> Best, 
> Marco. 
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to