Why return None?

Peter Hansen peter at engcorp.com
Thu Aug 26 07:08:39 EDT 2004


Martin DeMello wrote:
> Peter Hansen <peter at engcorp.com> wrote:
>>By the way, the second version is much more readable than
>>the first, so perhaps there is a secondary reason for this
>>"return None" thing in addition to the more important one...
> 
> It depends on what you're doing - to me, the first is simply "the
> normalised vector (a,b,c)", inlined. It's a single concept, much like an
> inlined string is - would you want to do the following?
> a = "Hello "
> a = a + str(name)
> print a

I'd want to do neither, often.  If I had to do either, often,
I would write a function which did the required operations
and I'd call that instead.  Then both it and the calling
code are readable.  But I suppose that's just me... maybe
others would prefer to repeat things more.

-Peter



More information about the Python-list mailing list