Steven D'Aprano <steve+comp.lang.python <at> pearwood.info> writes:

> # With chaining
> thing = func(MyClass().spam().eggs().cheese(), 
>              MyClass().aardvark(),
>              OtherClass().fe().fi().fo().fum(),
>              )
> do_stuff_with(thing)
> 
> versus:
> 
> # Without chaining
> temp1 = MyClass()
> temp1.spam()
> temp1.eggs()
> temp1.cheese()
> temp2 = MyClass()
> temp2.aardvark()
> temp3 = OtherClass()
> temp3.fe()
> temp3.fi()
> temp3.fo()
> temp3.fum()
> thing = func(temp1, temp2, temp3)
> do_stuff_with(thing)
> 

Another use case might be in comprehensions and generator expressions ??

thing = [MyClass().spam().eggs(x).cheese() for x in sequence]

where you can't use all those temporary assignments.

Best,
Wolfgang


-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to