1

I've a python project using PyDev in Eclipse. For sample code like below,

var = 'element'
width = 11
print(f'{var:>{width}}')

the code is executed printing the desired output element with right alignment and no errors.

However, PyDev parses this code raising error at > character and an error message SyntaxError: Unbalanced '{'. But PyDev does support double braces in f-strings since release 6.3.1 (#PyDev-884). If I remove this > character, the string is printed 'left-aligned' (which I don't want) and PyDev doesn't raise any error. This confirms PyDev does support double braces, but the error message is incorrect.

On the other hand, PEP 498 for f-strings doesn't mention anything about alignment using f-strings. Is alignment part of the f-string syntax? If it is why is it not mentioned in PEP guide, and why does PyDev parser raise an error?

  1. Python: 3.6.3
  2. PyDev: 6.3.3
  3. Eclipse: Oxygen.2 (4.7.2)

Thanks!

4

1 回答 1

2

这是 PyDev 中的一个问题(不幸的是https://www.python.org/dev/peps/pep-0498/没有为 f-strings 提供语法,并且对预期的解析应该如何进行非常简单——我'将更新 PyDev 以涵盖提供的示例)。

于 2018-06-21T13:32:34.710 回答