-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw an error when the number of variables on the LHS of an assignment doesn't match the number of elements on the RHS #18312
Comments
Especially it might be clearer if we introduce |
The current behavior seems kind of Matlab-inspired, I think. It's really useful for a function like As discussed on the mailing list, it also allows you to add outputs to a function that already returns a tuple without breaking most existing code. |
If the caller only wants the first two elements of the return tuple, they can always explicitly write |
@jrevels, yes, they can call |
Not having to explicitly call |
Is it at least possible to retain |
We generally allow trailing commas in as many places as possible, so e.g. |
Apologies if this is a dup, I thought I saw an issue for this a while ago, but couldn't dig it up.
The current behavior:
@andreasnoack, @vchuravy and I think this behavior's bug-proneness-to-usefulness ratio might be a bit high. We should be consider making it an error. Users could easily (and more clearly) write
x, y = take((1,2,3), 2)
to accomplish the same thing.The text was updated successfully, but these errors were encountered: