Skip to content

Instantly share code, notes, and snippets.

@raeq
Last active May 2, 2021 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raeq/d48f2aedaa664ed2a89d68c0f36058bb to your computer and use it in GitHub Desktop.
Save raeq/d48f2aedaa664ed2a89d68c0f36058bb to your computer and use it in GitHub Desktop.
With Annotations
from functools import singledispatch
@singledispatch
def area(any_object):
raise NotImplementedError
@area.register
def _(any_object: Circle):
return math.pi * (math.pow(any_object.radius, 2))
@area.register
def _(any_object: Square):
return (math.pow(any_object.length, 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment