Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python

#pip install danielutils
from danielutils import overload

class Foo:
    def __init__(self):
        pass
        
	#'None' to skip
    @overload(None, int)
    def __add__(self, other):
        return 1

    @overload(None, str)
    def __add__(self, other):
        return 2
      
@overlaod(str,[int,float])
def bar(name,age):
	return 3
  
@overload(str,str)
def bar(name,color):
	return 4
  
if __name__ == '__main__':
    print(Foo()+5) #-> 1
    print(Foo()+"s") #-> 2
	print(bar("jake",5)) #-> 3
    print(bar("jake",5.5)) #-> 3
    print(bar("jake","blue")) #-> 4
Source by github.com #
 
PREVIOUS NEXT
Tagged: #python
ADD COMMENT
Topic
Name
7+2 =