Glossary: Software Design Patterns
Duck typing
Python cares what an object can do, not what class it is: if it has the right methods, it works. `apply_discount` accepts any rule that has `applies` and `apply` methods.
Glossary: Software Design Patterns
Python cares what an object can do, not what class it is: if it has the right methods, it works. `apply_discount` accepts any rule that has `applies` and `apply` methods.