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.
Add words for autocompletion feature (for both console and editor)
-
Hi, very happy to know omz is come back!
I've a question related to autocompletion.
Which is the easiest way to add a list of words/commands in autocompletion database of Pythonista without writing a library and importing it?
I know that if user writes a library with some definitions and import all function, definitions, classes, etc.. Pythonista can recognize the name of the definitions and user can write the names with autocompletion support (both in console and editor). I ask if it is possible without writing a library, but by adding some words in autocompletion database, if it exists.Example of use: I'd like to save often-used words in the database and while typing in the editor, Pythonista helps me to choose that words, that begin with the letters I have typed in the editor or console, from the database, to speed up the writing.
Thank you
Regards -
@Matteo said
I know that if user writes a library with some definitions and import all function, definitions, classes, etc.. Pythonista can recognize the name of the definitions and user can write the names with autocompletion support (both in console and editor)
How do you that?
-
@Matteo You could use Pythonista snippets, for editor, not for console
-
@cvp Hi! When user writes some definitions and executes once the script, Pythonista recognizes the name of definitions.
For example if in my lib script 'mylibs.py' I writedef test(): None
and I execute once mylibs.py, I can select word 'test' for autocompletion, in editor and in console, until I reset Pythonista environment (RAM).
About snippets I don't know what it is. Can you tell me something about it?
Thank you
Regards -
@Matteo see Pythonista settings like https://imgur.com/a/N5sW5O2
You can add words even without snippet and if you begin by typing its initials, you will see....
Define https://imgur.com/a/R9ev8DS
-
@cvp Thank you for hint about snippet, never used it since I have Pythonista. I will try to use it for adding words.
About your last image link, how can I add words without snippet? I think it could be what I need.Thank you!
Edit: sorry, I've seen now your link about Define, ok, solved. Ignore my previous question.
Best regards -
@Matteo That does not solve the usage in console ...
-
@cvp Yeah, you are right. Also in editor when I try to select an empty snipped just created, Pythonista doesn't insert the word in editor, I can see the word but it is not added in editor, tried just now (v3.1, 301016).
For usage also in console the only way is to write a py file with a list of None definitions, but I think there isna better and simpler way.
I must perform some experiments with snippets.
Again thank you for help.
Bye -
@cvp said
I can see the word but it is not added in editor
You are right, sorry, I did not test it... 😭
Then you have to put the same word as snippet, I guessTested, that works but needs to type twice the word in the settings
-
@cvp ok, it works now.
Thank you cvp
ByePs: do you know a way to change programmatically all snippets in order to add some special character to all snippets, for example?
-
@Matteo asked
do you know a way to change programmatically all snippets in order to add some special character to all snippets, for example?
No idea where there are stored...
But why?
-
@cvp ok, suppose I have a lot of snippets created by hand that start with a specific word, for example 'scipy.xxx' where 'xxx' are some words. How can I change word 'scipy' in 'basic.scipy' (for example) for all snippets of the form 'scipy.xxx'? It is just to add, modifiy, rename, change content of snippets programmatically to be faster than changing them by hand one by one.
If snippets are saved in a file , maybe it could be easier to change content of the file based on certain rules (with python regex for example).Thanks
-
@Matteo understood but no idea how and where are stored these snippets. And don't forget that even if you find the name of the eventual file, Pythonista files are often (always) write protected
-
@cvp maybe that file is writable by user, if user can add , delete, modify by hand snippets. But as you said if user can't see that file in visible directories, probably it is write protected. The best solution for me that works also for console remains the execution of a py file at Pythonista startup with a series of definition like:
def scipy.x1: None def scipy.x2: None ...
Thank you cvp for snippets solution, I've seen it is powerful with common pieces of code user uses often.