re Challenge: More Compact?

Tim Hammerquist tim at vegeta.ath.cx
Mon Jul 16 16:03:33 EDT 2001


[ please don't reply and post ]

Me parece que Thomas Wouters <thomas at xs4all.net> dijo:
> On Mon, Jul 16, 2001 at 02:39:50AM +0000, Tim Hammerquist wrote:
> 
> > I'm in the habit (in Python as well) of return undef on
> > false because in some methods, 0 is ambiguous.  So, in cases where 0 is
> > not ambiguous, 0 is idiomatically preferred to None?
> 
> You wouldn't call those functions in a boolean context, now would you ? I
> prefer to return -1 if 0 is a valid return value, or just raise an exception
> if -1 is valid as well. We're talking an entirely different function though,
> one where an 'error return' really is exceptional. 

A valid point.  =)

> > Ok, so here's my version (I hate wasted line space and unnecessary temp
> > vars):
> 
> Just wait until you revisit this code in 6 months ;)

Actually, never had a problem understanding my own code.  The only
problem I've had understanding other people's code is when their
indentation is deplorable (which obviously doesn't apply to Python).
<wink>

-- 
Sometimes we can choose the path we follow.
Sometimes our choices are made for us.
And sometimes we have no choice at all.
    -- Morpheus, The Sandman



More information about the Python-list mailing list