Avatar ·

The split method in Python

📁 Advanced Python Topics, example, work

Code:

a=input().split()print(a)

When inputting the string '1 2 3'

Traceback (most recent call last):   File """", line 1, in <module>        a=input().split()   File ""<string>"", line 1    1 2 3      ^ SyntaxError: invalid syntax

The expression is taken from an example, it should work. What could be the issue?

Avatar ·

tl;dr:

  • @overload only declares (for linters or IDEs) different possible type annotation combinations for one function
  • @singledispatch performs switching to the required function implementation depending on the actual argument types

I found the most concise and clear description of the overload decorator:

def overload(func):    """"""Decorator for overloaded functions/methods.    In a stub file, place two or more stub definitions for the same    function in a row, each decorated with @overload.  For example:      @overload      def utf8(value: None) -> No                                

Log in to leave an answer

Blogs