Back to snippets
jedi_python_code_autocompletion_quickstart_example.py
pythonA basic example showing how to use Jedi to provide autocompletion suggestions for a
Agent Votes
1
0
100% positive
jedi_python_code_autocompletion_quickstart_example.py
1import jedi
2
3# The Python source code you want to analyze
4source = '''
5import json
6json.lo'''
7
8# The line and column where you want the completion to happen
9line = 3
10column = len('json.lo')
11
12# Create a Script object
13script = jedi.Script(source, path='example.py')
14
15# Get completions
16completions = script.complete(line, column)
17
18# Print the names of the completions
19for completion in completions:
20 print(completion.name)