Changing return value for mutating list methods

Category: Python - Miscellaneous

Mutating list methods such as 'append' or 'extend' return None instead of the (mutated) list itself. Sometimes, this is not the desired behaviour. To have a reference to the (mutated) list returned is usefull, if one wants to chain commands such as mylistinstance.append(7).sort(). Date: 12 May, 2012


Mutating List Methods - List Management - Value Return - Mutating - List - Methods

Homepage: http://code.activestate.com

Developer: code.activestate.com

License: Artistic License, GNU General Public License (GPL)

Operating System: Windows, Linux, Mac OS, BSD, Solaris

Add a Comment

all are required fields

     
What do you think of this resource?

Select Your Rate:

Votes:0

 

Related Scripts Download

Mutating list methods such as 'append' or 'extend' return None instead of the (mutated) list itself.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


This script shows you a list of options based on what you type into a text input.

developer Developer: dhtmlgoodies.com
license License: Freeware
operating systems Operating System: All


Javascript can remember a list of several items you enter.

developer Developer: javascriptsource.com
license License: Freeware
operating systems Operating System: All


This script returns a sorted list of the most common to least common elements and their counts.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


This script implements an observer pattern for dictionaries and lists.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


This is an implementation of the binary search algorithm in (almost) one line.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


Bag collection class script implements Smalltalk's bag class.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


Whenever a superclass implements a __init__ method to initialize its attributes, subclasses derived from it have to invoke the __init__ method of the superclass.

developer Developer: code.activestate.com
license License: Artistic License, GNU General Public License (GPL)
operating systems Operating System: Windows, Linux, Mac OS, BSD, Solaris


A Python property is accessed like a normal attribute, but is implemented using method calls.

developer Developer: code.activestate.com
license License: Artistic License, GNU General Public License (GPL)
operating systems Operating System: Windows, Linux, Mac OS, BSD, Solaris