Pythonification of the asterisk-based collection packing/unpacking syntax

Chris Angelico rosuav at gmail.com
Mon Dec 26 16:05:18 EST 2011


On Tue, Dec 27, 2011 at 7:58 AM, Eelco <hoogendoorn.eelco at gmail.com> wrote:
> What you are talking about goes by the name of a 'dynamic type CHECK';
> some kind of syntactic sugar for something like
> 'assert(type(obj)==sometype)'. Like a 'type cast', this is also a
> runtime concept...
>
> By contrast, here is the first google hit for 'type constraint'.
>
> http://msdn.microsoft.com/en-us/library/d5x73970.aspx
>
> "...you can apply restrictions to the kinds of types ... by using a
> type that is not allowed by a constraint, the result is a COMPILE-TIME
> ERROR" (emphasis mine)

A constraint can be applied at compile time or at run time. It'd be
valid to apply them at edit time, if you so chose - your editor could
refuse to save your file until you fix the problem. Doesn't mean a
thing. Python, by its nature, cannot do compile-time type checking.
Under no circumstances, however, does this justify the use of the term
"constraint" to mean "utterly different semantics of the same code".

ChrisA



More information about the Python-list mailing list