home ~ socials ~ projects ~ rss

Nice Code Formatting Conversion On Python Site

January 2013

The [documentation on the official Python site][1] site has a nice little design feature in its code examples. Each one starts out formatted for Python's "interactive interpreter" and show the expected results. For example, this snippet from the [Output Formatting][2] section:

My apologies. I haven't added alt text to this image yet.

If you click the little >>> symbol in the upper left corner, the code instantly jumps to a format suitable for being run in a file. The expected out also disappears making the snippet ready to copy and paste directly into a file.

My apologies. I haven't added alt text to this image yet.

That's an incredibly useful feature. Very nicely done, Python doc crew.

end of line

Footnotes

[1]: http://python.org/doc/

[2]: http://docs.python.org/3/tutorial/stdlib2.html#output-formatting

Share link:
https://www.alanwsmith.com/en/20/em/uw/m9/?nice-code-formatting-conversion-on-python-site