[Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method
Ben Finney
ben+python at benfinney.id.au
Fri May 21 04:24:37 CEST 2010
Cameron Simpson <cs at zip.com.au> writes:
> On 20May2010 17:46, Ben Finney <ben+python at benfinney.id.au> wrote:
> | Would it help if the traceback showed the ‘repr()’ of each of the
> | arguments received? That way it would be much clearer when the instance
> | was received as the first argument.
>
> I've occasionally passed large or deep dicts etc to functions and
> foolishly printed their repr in debug statements. They can be...
> wordy. Maybe a cropped repr, or the .__class__ attribute?
Okay. My main point is that I'm offering this as a way of avoiding a
special-case message for method calls versus non-method calls.
In Python, all function calls are essentially the same, and I think it's
too complicated for the message to differ depending on the syntax used.
Emitting the arguments in some form, or even the types of each argument,
in the message would make it clearer without a special case.
--
\ “We now have access to so much information that we can find |
`\ support for any prejudice or opinion.” —David Suzuki, 2008-06-27 |
_o__) |
Ben Finney
More information about the Python-Dev
mailing list