[Python-ideas] Method chaining notation

spir denis.spir at gmail.com
Sun Feb 23 12:29:01 CET 2014


On 02/23/2014 03:25 AM, Nick Coghlan wrote:
>
>> list_of_numbers = [1,2]
>> list_of_numbers.append(3)
>> list_of_numbers.append(4)
>> list_of_numbers.append(5)

As a side-note: There is no need in python for such constructs as proposed. As 
noted previously, most of them happen at init time (or more generally at object 
conctruction time), as in your example, and python proposes better constructs 
for that.

>> Now write that without repeating list_of_numbers all the way down the line.
> The thing is, this *isn't an accident*, it's a deliberate choice in
> the library design to distinguish between data flow pipelines that
> transform data without side effects, and repeated mutation of a single
> object (although reading Guido's earlier reply, that may be me
> retrofitting an explicit rationale onto Guido's personal preference).
>
> Mutation and transformation are critically different operations, [...]

I approve all what you say (if i understand right). Except that your choice of 
terms is rather misleading: mutation and transformation are just synonyms. What 
you mean (if i understand right) is mutation (of an existing piece of data) vs 
creation (of a new, and different, piece of data).


d




More information about the Python-ideas mailing list