In my opinion, fluent APIs are rarely needed in Python.
Optional keyword arguments in python allow, in a single function call, to specify a subset of required arguments.
For instance, one may argue that this interface is easier to use than fluent API:
Fluent APIs are more convenient in Java for instance, where keyword arguments are not a thing, and every single argument for every function must be specified. It is very common for builders in java to be fluent, where the user may only specify some arguments but not all.
Having said that, there is at least one instance where I really appreciate a fluent API in python: a chain of transformations where the intermediate objects are unwanted (and might cause confusion).
This is common in data manipulation and very useful in the Pandas library.
Here is a small snippet from a blog post about pandas I was too lazy to read: gist.github.com/adiamaan92/740405b...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In my opinion, fluent APIs are rarely needed in Python.
Optional keyword arguments in python allow, in a single function call, to specify a subset of required arguments.
For instance, one may argue that this interface is easier to use than fluent API:
ExampleNotFluent
can be immutable, great!Fluent APIs are more convenient in Java for instance, where keyword arguments are not a thing, and every single argument for every function must be specified. It is very common for builders in java to be fluent, where the user may only specify some arguments but not all.
Having said that, there is at least one instance where I really appreciate a fluent API in python: a chain of transformations where the intermediate objects are unwanted (and might cause confusion).
This is common in data manipulation and very useful in the Pandas library.
Here is a small snippet from a blog post about pandas I was too lazy to read:
gist.github.com/adiamaan92/740405b...