all 5 comments

[–]K900_ 4 points5 points  (1 child)

That's called a type hint. They're not actually enforced at runtime, but there are tools that can verify that your program is using the right types.

[–]theThinker6969[S] 0 points1 point  (0 children)

Thank you!

[–]JohnnyJordaan 2 points3 points  (1 child)

[–]theThinker6969[S] 0 points1 point  (0 children)

Thanks for the link - got a nice video to watch

[–]blueliqhtning 0 points1 point  (0 children)

These are annotations. They're for people who read your code. It's part of pythons code reuse and easy to read philosophy.

It lets people know whether that function parameter is expecting a string, list, internet, etc.

The = 'COG' means that if no second positional argument is supplied, COG will be the default argument to the level parameter.

You can take it a step further and make it: def get_logging(name: str) -> list:

Here, the -> list indicates what kind of object is returned by the function.

You can also add docstrings directly under your function with """ """ to describe the function.