What these functions do is that when the function is defined, The function is immediately called, which saves time and extra lines of code (as compared to calling it on a seperate line).
Actually, the above function will be treated as function expression without a name. The main purpose of wrapping a function with close and open parenthesis is to avoid polluting the global space.
12 The function* type looks like it acts as a generator function for processes that can be iterated. C# has a feature like this using "yield return" see 1 and see 2 Essentially this returns each value one by one to whatever is iterating this function, which is why their use case shows it in a foreach style loop.
Note that there’s no semicolon; this is just a function declaration. You would need an invocation, foo(), to actually run the function. Now, when we add the seemingly innocuous exclamation mark: !function foo() {} it turns it into an expression. It is now a function expression. The ! alone doesn’t invoke the function, of course, but we can now put () at the end: !function foo() {}(), which ...
PEP 3107 -- Function Annotations described the specification, defining the grammar changes, the existence of func.annotations in which they are stored and, the fact that it's use case is still open. In Python 3.5 though, PEP 484 -- Type Hints attaches a single meaning to this: -> is used to indicate the type that the function returns.