.local()
BrandonDusch580 total contributions
Published Jun 3, 2022
Contribute to Docs
The .local()
method returns a local thread object with data that is specific to that thread. This data can be anything from arbitrary numbers to session-specific information like usernames.
Syntax
threading.local()
No parameters are used in the .local()
method.
Example
Data can be locally stored as a property in a specific thread, as shown in the example below:
The output would look like this:
12
Codebyte Example
Additionally, the object returned by .local()
can be assigned to a variable, which is then stored in memory. Any stored data can be found in the local thread’s predefined __dict__
attribute:
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.