Enter partial function application with a builder pattern. The following code highlights how one might create reusable functions without creating a domain specific class hierarchy.
Take the boto3 library. More specifically, take the scan function for a dyanmodb table. The following is an example of how one could use this concept to produce a convenient way to iterate through all items in a dynamo collection.
Now that we have these two simple base classes we can iterate through a collection of dynamodb objects using the following code.
Hopefully you found this code example useful. If you have any questions please leave a comment and I’ll try to help with an answer.