what do these mean

e-mail mgbg25171 mgbg25171 at blueyonder.co.uk
Sun May 20 12:52:11 EDT 2012


There's a little forth program written in python here
#http://openbookproject.net/py4fun/forth/forth.py
I'm struggling to understand what these lines mean.

def rJnz (cod,p) : return (cod[p],p+1)[ds.pop()]
def rJz  (cod,p) : return (p+1,cod[p])[ds.pop()==0]

Specifically I'm stuck on what (code[p], followed by p+1 does inside the
brackets
and also what [ds.pop()] abd [ds.pop==0] does afterwards
I do know that
p is an integer
cod[p] is one of a list of functions that are stored in cod
ds.pop() is popping the top of the ds list and
ds.pop() == 0 either means that the result popped is 0 or that there are no
items left in list ds[]

Any help much appreciated
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120520/382d5543/attachment.html>


More information about the Python-list mailing list