in reply to Re: Evolution of python
in thread Evolution of python

Instead of braces, Python uses specific indenting instead. It provides the exact same functionality as Perl's scoping braces:

I don't believe that this is true. I think that my $variable cannot be specified in Python. There does seem to be some differences offered by Perl.

Replies are listed 'Best First'.
Re^3: Evolution of python
by Corion (Patriarch) on Jul 07, 2019 at 18:05 UTC

    Python does not have lexical scope for variables. It has more or less dynamic scope.

    This is not relevant to the mechanism that provides the scoping levels, be it braces or indentation.

      Not sure what you mean with lexical "scope", but python has closures.

      I have problems to see a way to create those without lexical variables.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        Lexical variables and closures don't need each other, unless you define a closure as something that closes over its lexical variables.

        x = "Hello"; # a global variable def make_closure(arg): arg = arg # make arg a lexical variable return lambda y, arg=arg: print(x,y,arg)

        The indentation or braces are (mostly) equivalent in defining where a name/value binding may be visible, but that has nothing to do with closures.

        And the OP issue of not knowing where/how a variable can be declared limited to a scope isn't an issue IMO because both Perl and Python have variables with limited scope which aren't visible "upwards".