Top "Scope" questions

Scope is an enclosing context where values and expressions are associated.

How to create module-wide variables in Python?

Is there a way to set up a global variable inside of a module? When I tried to do it …

python variables singleton module scope
Declaring an enum within a class

In the following code snippet, the Color enum is declared within the Car class in order to limit the scope …

c++ class enums namespaces scope
Short description of the scoping rules?

What exactly are the Python scoping rules? If I have some code: code1 class Foo: code2 def spam..... code3 for …

python scope dynamic-languages
Angular 2 - Using 'this' inside setTimeout

I have a function like so in my class showMessageSuccess(){ var that = this; this.messageSuccess = true; setTimeout(function(){ that.messageSuccess = …

javascript angular scope
Global variables in Javascript across multiple files

A bunch of my JavaScript code is in an external file called helpers.js. Inside the HTML that calls this …

javascript scope global-variables global
What's the correct way to communicate between controllers in AngularJS?

What's the correct way to communicate between controllers? I'm currently using a horrible fudge involving window: function StockSubgroupCtrl($scope, $http) { $…

scope angularjs
How to choose the right bean scope?

I noticed that there are different bean scopes like: @RequestScoped @ViewScoped @FlowScoped @SessionScoped @ApplicationScoped What is the purpose of each? …

jsf jsf-2 scope managed-bean
How do I access previous promise results in a .then() chain?

I have restructured my code to promises, and built a wonderful long flat promise chain, consisting of multiple .then() callbacks. …

javascript scope promise bluebird es6-promise
shared global variables in C

How can I create global variables that are shared in C? If I put it in a header file, then …

c variables linker global-variables scope
Don't understand why UnboundLocalError occurs (closure)

What am I doing wrong here? counter = 0 def increment(): counter += 1 increment() The above code throws an UnboundLocalError.

python scope closures global-variables