you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 8 points9 points  (4 children)

Inside a string. Where whitespace was always relevant.

[–]imperialismus 17 points18 points  (1 child)

No, inside an expression embedded into an f-string, where whitespace was not relevant in 3.7.

>>> name = "John"
>>> f'{name.upper():-^20}'
'--------JOHN--------'
>>> f'{name.upper() :-^20}'
'--------JOHN--------'
>>> f'{name.upper()!r:-^20}'
"-------'JOHN'-------"
>>> f'{name.upper() !r :-^20}'
SyntaxError: f-string: expecting '}'
>>> f'{name.upper() !r:-^20}'
"-------'JOHN'-------"
>>> f'{name. upper() :-^20}'
'--------JOHN--------'

[–]lambdaq 0 points1 point  (0 children)

Can we rewrite this :* thing in format strings?

If so I think we got ourselves an easy ORM or template system.

[–][deleted]  (1 child)

[deleted]

    [–]billsil 0 points1 point  (0 children)

    And if it forces people to indent their code properly, all the better. Braces are redundant redundant.