Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 20. Descriptors, Decorators,and ... > Allowing Chaining of Mutating List M...

Recipe 20.11. Allowing Chaining of Mutating List Methods

Credit: Stephan Diehl, Alex Martelli

20.12.1. Problem

The methods of the list type that mutate a list object in place—methods such as append and sort—return None. To call a series of such methods, you therefore need to use a series of statements. You would like those methods to return self to enable you to chain a series of calls within a single expression.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial