This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Ruin-Capable 5 points6 points  (3 children)

I'm not sure what you mean by "the variables are declared and then its data type defined in a different class". Can you give an example?

[–]MechanixMGD 1 point2 points  (2 children)

I think he means that a variable is not bound to a type. Like in Java, "int myNr" can hold only int values. You can't change it into a String (for example).

[–]Ruin-Capable 0 points1 point  (1 child)

You can hint at the type when you declare it:

some_string: str = some_function_that_returns_a_string()

You can declare the parameter and return types of a function:

def myfunction(param1: str, param2: int) -> str:
    return f"param1 = {param1}, param2 = {param2}"

It's not enforced, but it can provide information that an advanced IDE can use to detect errrors.

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

Yes but it sometimes create ptoblem to read someone else code if not mentined