Static Typing in Python
Premshree Pillai
premshree_python at yahoo.co.in
Mon Mar 15 21:16:18 EST 2004
--- Peter Hickman <peter at semantico.com> wrote: >
Jacek Generowicz wrote:
> > Peter Hickman <peter at semantico.com> writes:
> >>Premshree Pillai wrote:
> >>>Like in C, C++, etc, Python too is
> >>>strongly typed, i.e., variables are necessarily
> bound
> >>>to a particular type.
>
> [deletia]
>
> > Secondly, you appear to be confusing C and C++
> with strongly typed
> > languages. A common mistake :-)
>
> No I was just taking Premshree's lead where he says
> 'Like in C, C++,
> etc, Python too is strongly typed'
>
> > Python is strongly typed because:
> >
> > - lots of type checking is done
> > - few implicit type conversions are done.
> > - No operations which are inappropriate to the
> object(s) in question
> > are allowed.
>
> Perhaps you should read the following where Guido
> van Rossum talks about
> typing in Python. Here he is contrasting strongly
> typed languages with
> Python.
>
> "In a strongly typed language, when you change to a
> different data
> structure, you will likely have to change the
> argument and return types
> of many methods that just pass these things on. You
> may also have to
> change the number of arguments, because suddenly you
> pass the
> information as two or three parts instead of one. In
> Python, if you
> change the type of something, most likely pieces of
> code that only pass
> that something around and don't use it directly
> don't have to change at
> all."
>
> It would seem to be clear that what Guido considers
> to be strong typing
> is not a feature of Python. As the following quote
> seems to indicate.
>
> "Weak typing is not really a fair description of
> what's going on in
> Python. It's really runtime typing because every
> object is labeled with
> a type."
>
> Here's the link
> http://www.artima.com/intv/strongweakP.html I would
> recommend reading www.artima.com to anyone
> interested in programming.
>
> So there we have it, Python is *NOT* strongly typed
> unless you know more
> about Python than Guido van Rossum.
>
> 1-0
> --
> http://mail.python.org/mailman/listinfo/python-list
Python is strongly typed...
Consider this:
>>> foo = "x"
>>> foo = foo + 2
Traceback (most recent call last):
File "<pyshell#3>", line 1, in ?
foo = foo + 2
TypeError: cannot concatenate 'str' and 'int' objects
>>>
The above returns a TypeError in Python, but not in
PHP, which is weakly typed.
Oh, well, you could accuse me of knowing more than
Guido :-)
-Premshree Pillai
=====
-Premshree
[http://www.qiksearch.com/]
________________________________________________________________________
Yahoo! India Insurance Special: Be informed on the best policies, services, tools and more.
Go to: http://in.insurance.yahoo.com/licspecial/index.html
More information about the Python-list
mailing list