[Trying to cut this short... We have too many threads for this topic. :-( ]

On 10/28/05, Nick Coghlan <[EMAIL PROTECTED]> wrote:
[on making args b/w compatible]
> I agree changing the behaviour is highly unlikely to cause any serious
> problems (mainly because anyone *caring* about the contents of args is rare),
> the current behaviour is relatively undocumented, and the PEP now proposes
> deprecating ex.args immediately, so Guido's well within his rights if he wants
> to change the behaviour.

I take it back. Since the feature will disappear in Python 3.0 and is
maintained only for b/w compatibility, we should keep it as b/w
compatible as possible. That means it should default to () and always
have as its value exactly the positional arguments that were passed.

OTOH, I want message to default to "", not to None (even though it
will be set to None if you explicitly pass None as the first
argument). So the constructor could be like this (until Python 3000):

def __init__(self, *args):
    self.args = args
    if args:
        self.message = args[0]
    else:
        self.message = ""

I think Nick proposed this before as well, so let's just do this.

> I'm talking about the specific context of the behaviour of 'return' in
> generators, not on the behaviour of ex.message in general. For normal
> exceptions, I agree '' is the correct default.
>
> For that specific case of allowing a return value from generators, and using
> it as the message on the raised StopIteration, *then* it makes sense for
> "return" to translate to "raise StopIteration(None)", so that generators have
> the same 'default return value' as normal functions.

I don't like that (not-even-proposed) feature anyway. I see no use for
it; it only gets proposed by people who are irked by the requirement
that generators can contain 'return' but not 'return value'. I think
that irkedness is unwarranted; 'return' is useful to cause an early
exit, but generators don't have a return value so 'return value' is
meaningless.

--
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to