does lack of type declarations make Python unsafe?
aleax at aleax.it
Thu Jun 19 19:12:34 CEST 2003
> [As usual, Alex demonstrates his logorrhea right before he has to vanish
> on a long trip. ;-) I was unable to read the whole thing, but managed
> to get far enough to nitpick something.]
"To nitpick, nitpick squared".
> In article <pNfIa.206219$g92.4232233 at news2.tin.it>,
> Alex Martelli <aleax at aleax.it> wrote:
>>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)
> Hmmmm.... I would only do that for a sequence. From my POV, classes,
I can't believe one could find ANY sensible objection to "doing that"
(checking len(c)) for a dictionary nor for a set. Either your nitpick
is very poorly expressed (something that should be particularly carefully
avoided when nitpicking) or it just makes no sense whatsoever to me.
> class instances (even those not implementing any special methods), and
> modules all serve as containers for the purpose of determining what an
> appropriate "container object" is for any particular program.
You may indeed choose to call a class (&c) "a container", because it
does contain some things, just as some (e.g.) C programmer might choose
to call a struct "a container" for the same reason. It's simply not
the common definition used in computer science (cfr. for example
http://www.xemacs.org/Documentation/packages/html/elib_3.html , &c).
More information about the Python-list