Vajrasky Kok added the comment:

Nice.

My only complain is the dis.dis example. We don't have to use redirect_stdout 
context manager.

+        # How to capture disassembly to a string
+
+        import dis
+        import io
+
+        f = io.StringIO()
+        with redirect_stdout(f):
+            dis.dis('x**2 - y**2')
+        s = f.getvalue()


dis.dis supports file object natively. We can do this instead:
dis.dis('x**2 - y**2', file=f)

----------
nosy: +vajrasky

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15805>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to