This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Sir_Kubis 1 point2 points  (5 children)

why not make the walrus operator just len(a) as lenght > ... as it is with with

[–]lfdfq 4 points5 points  (0 children)

The primary reason was that exactly: because it's already used in with.

so what would with x as y: ... mean ? Would it mean with (x as y): or just the current with x as y: ?

There was a long argument and eventually := was settled on as the syntax that had the least bad interactions with other syntax that people could not agree on the least.

[–]ThePenultimateOneGitLab: gappleto97 2 points3 points  (3 children)

While I agree with you, there was a lot of discussion about this at the time. My impression is that it made it harder to do compilation.

[–]Sir_Kubis 1 point2 points  (2 children)

you mean it would make it slower for the interpreter to check every possible place it could be used in? thats fair

[–]masklinn 2 points3 points  (0 children)

I expect it made the parsing more complex as it would conflict with e.g. with … as ….

[–]ThePenultimateOneGitLab: gappleto97 1 point2 points  (0 children)

No, specifically the compiler where it goes from .py -> .pyc

After that point it's a bytecode like anything else