PEP 285: Adding a bool type
Steve Holden
sholden at holdenweb.com
Tue Apr 9 18:50:35 EDT 2002
"Roy Smith" <roy at panix.com> wrote in message
news:roy-7658EF.08144409042002 at news1.panix.com...
> tanzer at swing.co.at (Christian Tanzer) wrote:
> > There are several dimensions to typing, including:
> > - static vs. dynamic
> > - strong vs. weak
>
> Putting it another way...
>
> In Perl, if I write "$x = 1;", x can act as either an integer or a string,
> depending on how I use it.
>
> In Python, if I write "x = 1", x can only act as an integer. In that
> sense, it's strongly typed. On the other hand, it's also true that
> sometimes later, I can say "x = '1'", and now x can only act as a string.
> At any particular point in time, its type is strongly defined, but the
type
> can also (dynamically) change from time to time.
>
> In Python, the variable (x) can change type, but the value itself (1)
> cannot. In Perl, the value itself can change type as coerced by the
> context.
It might be preferable to emphasise that variables have no type by
expressing the same idea as "The value bound to the name x can be of any
type, but in Python there are fewer implicit coercions than in Perl".
regards
Steve
More information about the Python-list
mailing list