global-variables

Python 2.7.2 global variables + tkinter

偶尔善良 提交于 2019-12-13 17:06:09
问题 I'm having some problems with the global variables: #Dev by Mkee import Tkinter as tk import sys, random globvar = 0 class Shuffle(object): def __init__(self,master=None): self.master=master self.text=tk.Label(master, text="Type in something:") self.box=tk.Entry(master) self.buttn = tk.Button(master, text="Done", width=10, command=self.calc()) self.result = tk.Label(self.master, text=globvar) def hide(self): self.text.pack_forget() self.box.pack_forget() self.buttn.pack_forget() self.result

Sharing data between es6 modules

拈花ヽ惹草 提交于 2019-12-13 16:51:35
问题 Is there a place where es6 modules (jspm/system.js & babel) can share data with each other (not window):? Ex: I have a parser module for http query strings. I use it at startup to choose which program to run (one html file running many programs). I also use it in the selected program to get flag values for running it. Example: triangles or squares, what number of them, world coord system ... etc. How do I share the result of the query string parse between the startup module and the various

How lazy can C++ global initialization be?

北战南征 提交于 2019-12-13 12:01:17
问题 I'm used to thinking of all initialization of globals/static-class-members as happening before the first line of main(). But I recently read somewhere that the standard allows initialization to happen later to "assist with dynamic loading of modules." I could see this being true when dynamic linking: I wouldn't expect a global initialized in a library to be initialized before I dlopen'ed the library. However, within a grouping of statically linked together translation units (my app's direct

How to access Local variables of functions when the function call has finished in python?

陌路散爱 提交于 2019-12-13 08:26:56
问题 I found on the net that local variables of functions can't be accessed from outside when the function call has finished.I try to execute the program but it throws an error that variable is not defined. My code is xyz=list() n=0 def length(g): i=0 n=g v=input("no of") while i<v: c=input("Enter the 1st dimension:") j=input("Enter the 2nd dimension:") i=i+1 xyz.append(c) xyz.append(j) return c return j return n def prod(): global c for i in xyz: if n<c and n<j: print "Upload another" elif n==c

Javascript Closure -Local variable nested function [duplicate]

旧巷老猫 提交于 2019-12-13 07:37:15
问题 This question already has answers here : Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference (6 answers) Closed 3 years ago . I am trying to use a variable x defined inside a function P whose value I am trying to set in another function. It always comes undefined. I tried applying my mind to use closure but it's just going off my head. It does not gives me a string rather a object. The logic is as follows. function P(i){ var x; if(i!=null){ /

Using global variable in function

删除回忆录丶 提交于 2019-12-13 07:24:42
问题 I have a very big dataset and I analyze it with R. The problem is that I want to add some columns with different treatments on my dataset AND I need some recursive function which use some global variable. Each function modify some global variable et create some variables. So the duplication of my dataset in memory is a big problem... I read some documentation: if I didn't misunderstand, neither the use of <<- nor assign() could help me... What I want: mydata <- list(read.table(), ...)

In Javascript/Coffeescript how can I mock out a module's public variable in a test?

℡╲_俬逩灬. 提交于 2019-12-13 05:44:39
问题 I just learned about the module pattern. I've written some code that's gotten sufficiently complex that I want to test a feature. The problem is, I can't figure out how to mock out a value. What follows is coffeescript, but I'll put the generated javascript below so I can get more help. Here's my test that attempts to mock out a field named state , but it always prints "undefined": root = exports ? this root.test3 = (-> root.test2.state = "abc" root.test2.doSomething() return {} )() And here

Using Global Variables between multiple functions in JQuery?

两盒软妹~` 提交于 2019-12-13 05:19:10
问题 I want to dynamically load an image using jQuery like this: main.js var slidersrc=""; //try to define global variable - not sure if this is correct jQuery(document).ready(function() { jQuery("#sliderimg").attr('src', slidersrc); }); jQuery("#selection1").click(function() { slidersrc='wp-content/themes/*****/slide1.png'; }); So the first time user access my website, the slider is empty. After user clicks on one of the selection areas, I set the global variable value. Then if user continues to

Static initialization order issue in C++

落花浮王杯 提交于 2019-12-13 05:17:05
问题 This is another variation of an old theme: The initialization order of static objects in different translation units is not defined. Below is a stripped-down example of my particular scenario. The classes G and F are non-POD types. F depends on G is the sense that to construct an instance of F you need some number of instances of G. (For example, F could be some message an application emits, and instances of G would be components of such messages.) G.hpp #ifndef G_HPP #define G_HPP struct G {

Global variable in nightwatch. Issue in for loop for node.js

眉间皱痕 提交于 2019-12-13 05:08:50
问题 I am currently working with node + nightwatch + selenium for automation. I came across a scenario: I have defined an array as Global array in nightwatch: Dev.js 'checkforLink':{ link1:"Some Xpath 1", link1:"Some Xpath 2", link1:"Some Xpath 3", link1:"Some Xpath 4" }, In my custom js script in custom-commands, I am doing a for loop to fetch this links from global variable: exports.command = function(callback) { browser = this; var data = browser.globals; console.log("Before all loop"); for(var