[C++-sig] Builtin python functions and the Object Wrapper

Brian Hall bhall at gamers-fix.com
Sun Jul 18 18:54:36 CEST 2004


Say I want to implement the following python code in C++ using the object
wrapper:

 

def tb_lineno(tb):

 

    c = tb.tb_frame.f_code

    if not hasattr(c, 'co_lnotab'):

        return tb.tb_lineno

 

    tab = c.co_lnotab

    line = c.co_firstlineno

    stopat = tb.tb_lasti

    addr = 0

    for i in range(0, len(tab), 2):

        addr = addr + ord(tab[i])

        if addr > stopat:

            break

        line = line + ord(tab[i+1])

    return line

 

 

How would I gain access to the len() and ord() builtin methods?

 

Thanks!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040718/808e5255/attachment.htm>


More information about the Cplusplus-sig mailing list