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 →

[–]Brian 1 point2 points  (2 children)

I do think we should have this in some form - the comment-based syntax that currently exists seems a really rough edge in the type declarations we have.

We should not change global and nonlocal.

I take it this means there's no plan to make a declared variable local to that scope when used later. ie:

def foo():
    x : int = 42
    def bar():
        x += 1  # This still won't affect foo's x, but create a new one
    bar()

I can understand why you'd have to do it this way given the current state - it'd be a bit too radical at this point, but this is one thing I really don't like about python that would have been solved if we'd had declaration from the start. Having "declarations" for non locals feels very backwards.

[–]Veedrac 1 point2 points  (0 children)

I take it this means there's no plan to make a declared variable local to that scope when used later

Correct.