dis.dis question

skip at pobox.com skip at pobox.com
Sat Oct 15 22:24:52 EDT 2005


    >> I'm still looking for info on how to use disassemble_string().

How about this?

    >>> import dis
    >>> def f():
    ...   print "hello world"
    ... 
    >>> f.func_code.co_code
    'd\x01\x00GHd\x00\x00S'
    >>> dis.disassemble_string(f.func_code.co_code)
              0 LOAD_CONST          1 (1)
              3 PRINT_ITEM     
              4 PRINT_NEWLINE  
              5 LOAD_CONST          0 (0)
              8 RETURN_VALUE   

Skip



More information about the Python-list mailing list