does lack of type declarations make Python unsafe?

Anton Vredegoor anton at vredegoor.doge.nl
Sun Jun 29 16:35:14 EDT 2003


david.abrahams at rcn.com (David Abrahams) wrote:
 <700+ LOP>
>Alex Martelli <aleax at aleax.it> writes:
<snip>
>> In Python one generally identifies (just as informally) a container as
>> "an object which has a length" (using "length", perhaps a suboptimal
>> choice of wording, to mean "number of items currently contained") and
>> simultaneously express both 'c is a container' and 'that container is
>> not empty' by
>>
>>     assert len(c)
>
>That understanding of "containerness" is, AFAICT, not universally held
>among Pythonistas by any means.  Good thing too, probably: it looks
>like there is no such thing as an empty container:
>
>     >>> assert len([])
>     Traceback ...

The following capture of an interactive session might be informative:

Python 2.3b1 (#2, Apr 26 2003, 15:09:25) 
[GCC 2.95.3-5 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> len({})
0
>>> len([])
0
>>> assert 0
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AssertionError
>>> 
<snip>
>I love a nice jestful debate.  Maybe your whole post is jestful and I
>failed to recognize it.  It certainly seems to have a derisive tone
>which makes it hard to see the love.  Where's the love, people?
>Anyway, if you tell me you didn't mean it that way I'll take your word
>for it.

Perhaps not love, to me both you guys are discussing trifles. TDD and
the source of it, static typing, are both about being satisfied with
just passing tests, while the really important discussion -for me at
least- is about aligning the code with ones thoughts, and how to
accomplish that. (I'm not yet talking about aligning ones thoughts
with the universe, I wouldn't know how to start that :-)

Maybe it's like the Zen of shooting arrows, not aiming at the goal,
but aiming to make the whole process flow naturally.

Confronting the Martellibot is like flirting with an encyclopedia, I'd
rather not do it myself, but I respect those who do, because it
produces knowledge.

Anton




More information about the Python-list mailing list