Perl is worse!

Steve Lamb grey at despair.rpglink.com
Sat Jul 29 18:34:19 EDT 2000


On 29 Jul 2000 02:50:37 GMT, Martijn Faassen <m.faassen at vet.uu.nl> wrote:
>Right -- that's why I didn't understand why you complained about the
>extensive exception checking or other checks you need in Python; if you
>*know* a string can be safely converted to an integer, int() does the
>job just fine by itself.

    Because Python can toss two types out.  String or None, only one of which
can be converted.

>Ahum, the first! Especially if it deals with critical data, or *money*.
>Imagine I get a string by accident (there's a bug in the program) instead
>of a number, and the string evaluates to 0, and suddenly what I'm selling
>in my e-commerce store is *free*, I'd be rather upset. I'd rather have the
>software not working in case of such input!

    Assumption it is dealing with money.  What about logs processing?

>It's not a meaningless statement. Sometimes it's very handy to get the
>representation of some Python object. For instance:

>>>> def foo(): pass
>>>> [many complicated steps later]
>...ah, but what is bar now?
>>>> bar
><function foo at 80c8f68>

    Right, I understand thta.  Which is why I keep pointing out that it is
meaningless in the context of a script.  You tell me why I would need to know
that in a script and maybe we can get around this.  I just see no need, ever,
for something that cannot be accessed by the script in the first place.

>In non-interactive mode it isn't useful, I think (I'd love to hear some
>cases outside the function call example) so we could propose a patch to
>Python that trips over this (in the case of non-calls).

    See, we're in agreement.

>That statement sounds good in rethorics, but in practice I'd rather
>have the computer give up on things if I'm trying to do things that
>don't seem to make any sense immediately. That way I need to remember
>less.

    To me it is remembering more.  "Now, this variable coming in from that
file over there, going through this code over here in a different module,
entering in here... was it converted twice or three times and what do I need
to do with it now."

    Vs.

    "Here it is, those checks said it is this, do it."

>Unless you made it possible that b contained something that couldn't be
>turned into a number, such as None. If you made that possible you aren't
>sure beyond all doubt that the variable contains a number, right?

    Which is, of course, a product of the lanauge.  I know it is going to be a
digit or empty.  Sad part is Python makes empty None and None mutable into
pretty much nothing.

>Sure, but it is the same in Python, right? Except that in the end you have
>to cast your integers to ints or whatever other thing you were expecting
>from your input.

    So why, then, when I have done the check should I have to do it, again,
for the sake of the language.

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
         ICQ: 5107343          | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------



More information about the Python-list mailing list