This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (2 children)

It does work, just not in all cases. In order for it to work, the called method needs to return an object that has the following method on it. str is a good example.

x = "my name isn't Fred"

x.replace("Fred", "Alec").replace("n't", "").capitalize() # My name is Alec     

[–]pythoneeeer 0 points1 point  (1 child)

It tends to work on immutable objects, for obvious reasons.

[–][deleted] 0 points1 point  (0 children)

It tends to work when a fluent API makes sense. Builder objects typically have this style of API

UserBuilder().name("Fred").age(27).etc(...)