Как можно изменить синтаксис?
def get_text_coord (s: str, i: int):
for row_number, line in enumerate (s.splitlines(keepends = True), 1):
if i < len(line): return f'{row_number}.{i}'
i -= len(line)
for tag in textbox.tag_names (): textbox.tag_remove (tag, 1.0, 'end')
s = textbox.get (1.0, 'end')
tokens = lexer.get_tokens_unprocessed(s)
for i , token_type, token in tokens:
j = i + len (token)
if token_type in token_type_to_tag: textbox.tag_add (token_type_to_tag [token_type], get_text_coord (s, i), get_text_coord (s, j))
textbox.edit_modified (0)
Python 3.4.3 жалуется на неправильный синтаксис:
Traceback (most recent call last):
File "coddy.pyw", line 46, in <module>
import coddy_syntax as syntax
File "src\coddy_syntax.py", line 52
if i < len(line): return f'{row_number}.{i}'
^
SyntaxError: invalid syntax
Как можно изменить синтаксис?
Ответы (1 шт):
Автор решения: eri
→ Ссылка
F строки появились в 3.6, до этого пишем
'{row_number}.{i}'.format(i=i,row_number=row_number)