Why return None?

Antoon Pardon apardon at forel.vub.ac.be
Tue Aug 31 03:46:45 EDT 2004


Op 2004-08-27, Alex Martelli schreef <aleaxit at yahoo.com>:
> Antoon Pardon <apardon at forel.vub.ac.be> wrote:
>    ...
>> > It should be pretty obvious, I think.  So, if you want to
>> > get an AttributeError exception when 'a' is a tuple or str, a.extend(b)
>> > is clearly the way to go -- if you want para-polymorphic behavior in
>> > those cases, a+=b.  Isn't it obvious, too?
>> 
>> No it isn't obvious. No design is so stupid that you can't find
>> an example for it's use. That you have found a specific use
>> here doesn't say anything.
>
> I can silently suffer MOST spelling mistakes, but please, PLEASE do not
> write "it's" where you mean "its", or viceversa: it's the most horrible
> thing you can do to the poor, old, long-suffering English language, and
> it makes me physically ill.  Particularly in a paragraph as content-free
> as this one of yours that I've just quoted, where you're really saying
> nothing at all, you could AT LEAST make an attempt to respect the rules
> of English, if not of logic and common sense.
>
> On to the substance: your assertion is absurd.  You say it isn't obvious
> that a.extend(b) will raise an exception if a is bound to a str or
> tuple, yet it patently IS obvious, given that str and tuple do not have
> a method named 'extend'.

That is a non sequitur, the fact that something is a given, doesn't
make that something obvious. I dare say that if you have two parts
of equal code, one that uses += and the other that uses extend,
it will not be obvious to the reader that you want to first
code to work only with lists and the other with strings and tupples
too. He can probably figure it out but IMO it is not the most clear
way to make that disticntion.


> Whether that's stupid or clever is a
> completely different issue, and one which doesn't make your "No it isn't
> obvious" assertion any closer to sanity one way or another.

IMO, obvious means, that it is the first thing that comes to mind
when someone reads the code. IMO it is not obvious in that sense.

-- 
Antoon Pardon



More information about the Python-list mailing list