Why does the "dis" module print?

Martin v. Loewis martin at v.loewis.de
Mon Aug 12 18:10:17 CEST 2002

tweedgeezer at hotmail.com (Jeremy Fincher) writes:

> It seems that it would be a lot easier to pull information out of the
> output of the dis.dis function if, instead of printing its results, it
> returned a list of the disassembled bytecodes.  Printing bytecodes
> from a returned list is trivial; making a list from the printed
> bytecodes is much less so.  Why does dis print instead of returning a
> list of bytecodes?

Because that is the most common use case - nobody wanted anything else
so far.

Applications that read byte code usually just use the dictionaries and
lists produced in dis.py; they don't need the chain of if statements
inside disassemble.


More information about the Python-list mailing list