Pythonification of the asterisk-based collection packing/unpacking syntax

Evan Driscoll edriscoll at wisc.edu
Sat Dec 17 22:03:01 EST 2011


On 12/17/2011 20:45, Chris Angelico wrote:
> 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
Sorry, I just subscribed to the list so am stepping in mid-conversation,
but "strong" vs "weak" typing does not have a particularly well-defined
meaning. There are at least three very different definitions you'll find
people use which are almost pairwise orthogonal in theory, if less so in
practice. There's a great mail to a Perl mailing list I've seen [1]
where someone lists *eight* definitions (albeit with a couple pairs of
definitions that are only slightly different).

I like to use it in the "automated conversion" sense, because I feel
like the other possible definitions are covered by other terms
(static/dynamic, and safe/unsafe). And in that sense, I think that
thinking of languages as "strong" *or* "weak" is a misnomer; it's a
spectrum. (Actually even a spectrum is simplifying things -- it's more
like a partial order.)

Something like ML or Haskell, which does not even allow integer to
double promotions, is very strong typing. Something like Java, which
allows some arithmetic conversion and also automatic stringification (a
la "1" + 1) is somewhere in the middle of the spectrum. Personally I'd
put Python even weaker on account of things such as '[1,2]*2' and '1 <
True' being allowed, but on the other hand it doesn't allow "1"+1.

Evan

[1]
http://groups.google.com/group/comp.lang.perl.moderated/msg/89b5f256ea7bfadb
(though I don't think I've seen all of those)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 552 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20111217/81ee83a3/attachment.sig>


More information about the Python-list mailing list