Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Access Pythonista Settings from Script
-
I’d like to write a script that checks the Pythonista settings from within the script. Specifically, I’d like to check the indentation settings - whether they are tabs or spaces, and the number of spaces. I couldn’t find anything on this topic in the documentation or forum, but sorry if I missed something on this topic. Any suggestions on how I might reference this information?
-
@Harum_Scarum try something like
import editor def main(): indent = '?' f = editor.get_text() lines = f.split('\n') for line in lines: if not line: continue if line[0] == '\t': indent = 'tab' break elif line[0] == ' ': n = len(line) - len(line.lstrip()) indent = str(n)+ ' blanks' break print(indent) main()
-
@Harum_Scarum sorry, my script finds what you do, not what the setting value is.
-
from objc_util import * >>> defaults=ObjCClass('NSUserDefaults').standardUserDefaults() >>> defaultsDict=defaults.dictionaryRepresentation() >>> defaultsDict['UseSoftTabs'] <b'__NSCFBoolean': 1> >>> defaultsDict['IndentationWidth'] <b'__NSCFNumber': 3>
type defaultsDict at the console to see all of the pythonista settings that you can check this way.
-
@JonB wow
-
Thank you!