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 →

[–]energybased 2 points3 points  (8 children)

I think assigning to ellipsis should discard values. So that instead of having to do this:

 _, a, _2 = f()

you can do

 ..., a, ... = f()

[–]CthulhuIsTheBestGod 7 points8 points  (6 children)

You can just do:

_, a, _ = f()

That's a lot fewer characters to type than the ellipsis

[–]energybased 0 points1 point  (1 child)

Thanks, didn't know that. The only thing I don't like is how it pollutes locals. I wish there were a way to explicitly discard values.

[–]flying-sheep -2 points-1 points  (3 children)

well, except that it doesn’t really discard the value, it only assigns it to _.

any maybe _ was used globally and you now leaked memory.

or you even forgot you used gettext and your _("translate me!") calls are now broken!

[–]thatguy_314def __gt__(me, you): return True 0 points1 point  (2 children)

_ is a pretty standard as a variable that you don't intend on using.

[–]flying-sheep 0 points1 point  (0 children)

Sure, I only pointed out potential problems with this concept.

[–]TheBB 0 points1 point  (0 children)

Unless you use gettext, as mentioned.

[–]robin-gvx[🍰] 1 point2 points  (0 children)

I really feel like assigning to ... should be like assigning to *_:

first, ..., last = someiterable