Pythonification of the asterisk-based collection packing/unpacking syntax

Chris Angelico rosuav at gmail.com
Sat Dec 17 21:45:35 EST 2011


On Sun, Dec 18, 2011 at 11:59 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> The usual test of a weakly-typed language is that "1"+1 succeeds (and
> usually gives 2), as in Perl but not Python. I believe you are confusing
> weak typing with dynamic typing, a common mistake.

I'd go stronger than "usually" there. If "1"+1 results in "11", then
that's not weak typing but rather a convenient syntax for
stringification - if every object can (or must) provide a to-string
method, and concatenating anything to a string causes it to be
stringified, then it's still strongly typed.

Or is a rich set of automated type-conversion functions evidence of
weak typing? And if so, then where is the line drawn - is upcasting of
int to float weak?

ChrisA



More information about the Python-list mailing list