[Tutor] decomposing a problem

Steven D'Aprano steve at pearwood.info
Tue Dec 25 23:38:50 EST 2018


On Tue, Dec 25, 2018 at 10:25:50PM -0500, Avi Gross wrote:

> class chainable_list(list):
>     """Same as list but sort() can now be chained"""
>     def chainsort(this, *args, **kwargs):
>         this.sort(*args, **kwargs)
>         return this

In Python, it is traditional to use "self" rather than "this" as the 
instance parameter.

Using "this" is not an error, but you can expect a lot of strange looks. 
Like a Scotsman in a kilt wandering down the middle of Main Street, 
Pleasantville USA.



-- 
Steve


More information about the Tutor mailing list