[issue23949] Number of elements display in error message is wrong while unpacking in traceback
Ulaga Nathan Mahadevan added the comment: I agree. I posted it as an enhancement request. Steven explained the expected message clearly. Thanks. On Tue, Apr 14, 2015 at 12:58 PM, Steven D'Aprano rep...@bugs.python.org wrote: Steven D'Aprano added the comment: The error message isn't wrong, just hard to understand. In your example, when it says need more than 4 values to unpack it means that it got four values on the right hand side, and needs five (which is more than four) to match what is on the left. When the error is the other way around, with too few targets on the left, the error message is more understandable: a, b = (1, 2, 3) gives ValueError: too many values to unpack (expected 2). Your example should be fixed to something similar. I think it would be useful for both cases to report expected %d, got %d rather than just one or the other. By the way, I don't think that changes to error messages will be back-ported to old versions like 3.2, but only added to the latest version. -- keywords: +easy nosy: +steven.daprano ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23949 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23949 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23949] Number of elements display in error message is wrong while unpacking in traceback
New submission from Ulaga Nathan Mahadevan: data = ['David',50,91.1,(2012,12,21)] print (Data = ,data) name,shares,price,date,value = data print(Name = ,name, , no of shares = ,shares,, unit price = ,price,, date of purchase = ,date) After running the script Data = ['David', 50, 91.1, (2012, 12, 21)] name,shares,price,date,value = data ValueError: need more than 4 values to unpack There are only 4 values to unback and not more than 4. The given number of elements are 4 and so required number is 4. The error message is not clear or confusing. -- messages: 240935 nosy: ulaganathanm...@gmail.com priority: normal severity: normal status: open title: Number of elements display in error message is wrong while unpacking in traceback type: enhancement versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23949 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com