3 ms·
And so you end up writing climb_the_wooden_ladder(l: WoodenLadder) plus climb_the_aluminium_ladder(l: AluminiumLadder) or press all into an OO hierarchy instead
by mharig 4y ago
And so you end up writing climb_the_wooden_ladder(l: WoodenLadder) plus climb_the_aluminium_ladder(l: AluminiumLadder) or press all into an OO hierarchy instead of
climb(thing):
'''Climb a thing with steps'''
# prevent run time crash:
if not hasattr(thing, 'getSteps'):
hitDeveloper()
- baq 4y agoNo, you define a Ladder (or Climbable if you’re feeling fancy today) Protocol and all remains good in the world.
- cfu28 4y agoNo need for OO hierarchy, just use a protocol
- mharig 4y agoOh, I missed the Protocol class of the typing module. Have to further investigate the usage of this. Thanks to you and baq!