Skip to content

Properly define what a closure means #150430

@tanzilrasheed

Description

@tanzilrasheed

Documentation

(rewritten by @picnixz)

Currently, the documentation does not use the term closure to refer to a function which has access to variables in its enclosing lexical scope. We could add the term to the glossary so as to avoid random definitions appearing on random blogs.

Original text

The wrong definition of closures of python is available all over the internet.

it is mentioned as "To form a closure it must be a nested function" and also it is only emphasizing that it only remembers it's enclosing scope.

instead the definition should be "A function that remembers the scope where it was created....."

First I got confused that it may be different in python as I wasn't able to find any formal official documentation for it, and in all other unofficial websites of python tutorial I found it as a "nested function"

I hope the formal definition will be added soon in python, as it is really terrible if there is no official documentaion and these incorrect definitions are spreading. Also because python is right now largely growing language.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir
    No fields configured for issues without a type.

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions