I have found the following best practice tips useful for formatting Pythonista code before posting it to GitHub:
One Time Setup:
- When looking at the list of files at the left of the Pythonisa screen, click the gear icon at the bottom left of the screen.
- When the "Settings" panel appears, tap "Indentation".
- Make sure that Tab Width is set to "4 spaces".
- Make sure that both "Soft Tabs (Spaces)" and "Show Mixed Indentation" are turned on.
- Tap "Done".
- Tap the gear icon again.
- When the "Settings" panel appears, scroll down and tap on "Actions Menu".
- Make sure that both "Copy Text" and "Convert Indentation..." are turned on.
Before Posting to GitHub:
- Open your code in the Pythonista Editor.
- From the Actions Menu in the upper right of the screen, tap "Convert Indentation" and then "Copy Text".
- Paste your code into GitHub.
Rationale:
PEP 8 makes it clear that Spaces are the preferred indentation method for Python. I know that personal preferences may vary but on an iOS device it is difficult to edit tabbed code on the GitHub webpages because the standard iOS keyboard (e.g. the keyboard in Safari) does not have a tab key. Entering a tab character on a GitHub web page involves a painfully tricky cut and paste operation on an iOS device while typing four space characters is trivial.
Pythonista's Soft Tab feature means that the tab key in the Pythonista Editor works as expected yet the resulting code has no tab characters. We get the best of both worlds with Soft Tabs: the convenience of a tab key but code that contains no tab characters. The other advantages of the above approach is that trailing whitespaces are eliminated, IndentationErrors are easier to fix, and tabs in comments are similarly aligned in both the Pythonista Editor and on GitHub.