[Python-ideas] Inline assignments using "given" clauses

Steven D'Aprano steve at pearwood.info
Fri May 11 11:37:44 EDT 2018


On Fri, May 11, 2018 at 11:40:51AM +0200, Jacco van Dorp wrote:

> I dont really like "given".
> 
> If we compare:
> 
> if m given m = re.match(stuff):
> 
> to
> 
> if m := re.match(stuff)
> 
> then I count 4+(name_length) more tokens and 2 more spaces. Since I
> believe := is perfectly clear, I don't see the reason for a far more
> verbose syntax.

I agree with Jacco here. We have to name the variable twice, even if it 
is only used once, and we have a relatively long keyword, five 
characters, longer than average for all keywords, and only one char 
short of the maximum.

I know the aim isn't to absolutely minimise the number of keystrokes, 
but it does seem strange to use such a long symbol which requires 
duplicating the target, unless the intent is to discourage people from 
using it.


-- 
Steve


More information about the Python-ideas mailing list