[Tutor] best practice: throw exception or set a flag?

Bill Felton subscriptions at cagttraining.com
Fri Feb 4 17:50:43 CET 2011


Um, yes, emphatically yes.  You missed the context, which was Smalltalk, and it is terms of Smalltalk that my reply is couched.
Yes, Python returns None.
Smalltalk returns self by default.
Given the dropped context, you are correct.
Given the context meant, I am.

regards,
Bill

On Feb 4, 2011, at 9:28 AM, Emile van Sebille wrote:

> On 2/4/2011 5:35 AM Bill Felton said...
> 
>> Um, not quite correct -- methods *without a specified return value* always return self, that is, the object which executed the method.
> 
> Um, no.  They return None.
> 
> >>> class Test:
> ...   def __init__(self):pass
> ...   def test(self):pass
> ...
> >>> a=Test().test()
> >>> a
> >>> print a
> None
> >>>
> 
> Emile
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list