Why return None?
Martin DeMello
martindemello at yahoo.com
Thu Aug 26 05:54:35 EDT 2004
Peter Hansen <peter at engcorp.com> wrote:
> Martin DeMello wrote:
>
> > It seems to be a fairly common pattern for an object-modifying method to
> > return None - however, this is often quite inconvenient.
> ...
> > this is actually getting in my way a lot when scripting Blender - for
> > instance, I can't say move(Vector([a,b,c]).normalize()), I have to do
> > a = Vector([a,b,c])
> > a.normalize()
> > move(a)
>
> 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
martin
More information about the Python-list
mailing list