Forum Archive

ThreeBackticks.py utility to format code snippets for this forum

ccc

This little utility is a bit overkill but what the heck...

ThreeBackticks.py

Many people initially have difficulty formating their Python code so it looks good in posts to the Pythonisa Forum. This script attempts to properly format your code with appropriate carrage returns and backticks so that it is ready to post to the forum.

Remember that you can edit your own posts by clicking the word edit at the top right of the post.

Edit: Fixed bug: The first letter of each line created in the TextView is capitalized which is suboptimal typing in Python code.

omz

Bug: The first letter of each new line created in the TextView is capitalized which is suboptimal typing in Python code.

You can turn that off by setting autocapitalization_type to ui.AUTOCAPITALIZE_NONE. While you're at it, you might also want to turn off auto-correction (tends to get in the way when writing code):

text_view.autocapitalization_type = ui.AUTOCAPITALIZE_NONE
text_view.autocorrection_type = False
ccc

Thx... Fixed in the code.

donnieh

Very cool. Very useful.