Questions tagged [global]

Refers to a space where variables and other items may be accessed from any scope.

4669 questions
45
votes
2 answers

Python RegExp global flag

Is there a flag or some special key in python to use pattern multiple times. I used to test http://gskinner.com/RegExr/ my RegExp, it worked correctly in it. But when testing in correct enviorment match only returns None. import re pattern =…
Metsavaht
  • 618
  • 1
  • 7
  • 10
44
votes
1 answer

How are global functions defined in Swift?

I wrote a simple function that displays an alert when it is called. I'd like to use this function in several viewControllers. Right now I have the same bit of code copy-pasted into the bottom of each viewController, but I can't help but think…
Erik
  • 2,299
  • 4
  • 18
  • 23
44
votes
9 answers

Why are global variables considered bad practice?

I keep seeing warnings not to use global variables in JavaScript, but it seems that the only reason people say that is because the clogs up the global namespace. I can imagine this being easily fixed by putting all of the variables into one big…
user1318416
  • 729
  • 1
  • 6
  • 11
43
votes
5 answers

In Python what is a global statement?

What is a global statement? And how is it used? I have read Python's official definition; however, it doesn't make a lot of sense to me.
Capurnicus
  • 8,171
  • 5
  • 18
  • 11
40
votes
1 answer

npm install bower using -g vs --save-dev

I'm new to node and using npm to both do some node, angular and Express tutorials. I have used bower before in a tutorial. I'm pretty sure I have installed it using -g already as when i run the bower -v command I get back 1.3.3 I am to understand…
Eric Bishard
  • 5,201
  • 7
  • 51
  • 75
40
votes
4 answers

Python global keyword vs. Pylint W0603

Pylint W0603 states: Using the global statement. Used when you use the "global" statement to update a global variable. PyLint just try to discourage this usage. That doesn't mean you can not use it ! I wonder why is it so? Is there any more…
Jovik
  • 4,046
  • 6
  • 24
  • 24
39
votes
6 answers

How does one clear or remove a global in julia?

Is there any syntax that does something similar to MATLAB's "clear" i.e. if I have a global variable "a". How do I get rid of it? How do I do the analog of clear a
Mateo
  • 1,494
  • 1
  • 18
  • 27
37
votes
4 answers

How do I set up global load balancing using Digital Ocean DNS and Nginx?

UPDATE: See the answer I've provided below for the solution I eventually got set up on AWS. I'm currently experimenting with methods to implement a global load-balancing layer for my app servers on Digital Ocean and there's a few pieces I've yet…
AJB
  • 7,389
  • 14
  • 57
  • 88
36
votes
6 answers

Passing Variable through JavaScript from one html page to another page

I have two pages - "page 1" and "page 2". On page 1 there's an text-box with a value of e.g. 100 and a button at the end. By pressing the button I want javascript to save the value of the textbox in a global (?) variable and jump to page 2. With…
Kronwied
  • 381
  • 1
  • 3
  • 4
35
votes
4 answers

Assign multiple objects to .GlobalEnv from within a function

A post on here a day back has me wondering how to assign values to multiple objects in the global environment from within a function. This is my attempt using lapply (assign may be safer than <<- but I have never actually used it and am not…
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
34
votes
3 answers

Global variable with imports

first.py myGlobal = "hello" def changeGlobal(): myGlobal="bye" second.py from first import * changeGlobal() print myGlobal The output I get is hello although I thought it should be bye Why doesn't the global variable myGlobal changes…
Joel
  • 5,949
  • 12
  • 42
  • 58
34
votes
1 answer

How Does Google Global Login Work?

Whenever I login to one Google service, I am automatically logged in all their other websites on different domains. What I want to know is how they are able to access the disparate cookies and sessions that belong on another domain. I tried…
Unknown
  • 45,913
  • 27
  • 138
  • 182
33
votes
3 answers

How to define a global variable that can be accessed anywhere in my application?

Possible Duplicate: Global int variable objective c I would like to create a global variable. I want to access to this variable anywhere. The Java equivalent: static var score:int = 0; For example if I define a global variables into the Game…
Benoît Freslon
  • 2,021
  • 4
  • 26
  • 35
32
votes
4 answers

bash background process modify global variable

In my Bash script, I have a global variable foo set to some value and a function process back_func that is run in the background. I would like the background process to be able to access foo and modify its value, so that the change can be seen by…
algosolo
  • 323
  • 1
  • 3
  • 7
31
votes
2 answers

setting seed locally (not globally) in R

I'd like to set seeds in R only locally (inside functions), but it seems that R sets seeds not only locally, but also globally. Here's a simple example of what I'm trying (not) to do. myfunction <- function () { set.seed(2) } # now, whenever I…
Manoel Galdino
  • 2,376
  • 6
  • 27
  • 40