name ‘times’ is used prior to global declaration – But IT IS declared

The global declaration is when you declare that times is global def timeit(): global times # <- global declaration # … If a variable is declared global, it can’t be used before the declaration. In this case, I don’t think you need the declaration at all, because you’re not assigning to times, just modifying it.

Can I simultaneously declare and assign a variable in VBA?

There is no shorthand in VBA unfortunately, The closest you will get is a purely visual thing using the : continuation character if you want it on one line for readability; Dim clientToTest As String: clientToTest = clientsToTest(i) Dim clientString As Variant: clientString = Split(clientToTest) Hint (summary of other answers/comments): Works with objects too (Excel … Read more

Can I declare variables of different types in the initialization of a for loop? [duplicate]

Yes, that is prohibited. Just as otherwise you cannot declare variables of differing types in one declaration statement (edit: modulo the declarator modifiers that @MrLister mentions). You can declare structs for (struct { int a = 0; short b = 0; } d; d.a < 10; ++d.a, ++d.b ) {} C++03 code: for (struct { … Read more

What is the purpose of a declaration like int (x); or int (x) = 10;

The fact that this rule is applicable in your case is not deliberate: It’s ultimately a result of keeping the grammar simple. There is no incentive to prohibit declarations such as yours, but there are great disincentives to complicate rules, especially if those are intricate as they are. In short, if you don’t want to … Read more

Why does `int ;` compile fine in C, but not in C++?

The C standard says A declaration other than a static_assert declaration shall declare at least a declarator (other than the parameters of a function or the members of a structure or union), a tag, or the members of an enumeration. C++ says In a simple-declaration, the optional init-declarator-list can be omitted only when declaring a … Read more

setq and defvar in Lisp

There are several ways to introduce variables. DEFVAR and DEFPARAMETER introduce global dynamic variables. DEFVAR optionally sets it to some value, unless it is already defined. DEFPARAMETER sets it always to the provided value. SETQ does not introduce a variable. (defparameter *number-of-processes* 10) (defvar *world* (make-world)) ; the world is made only once. Notice that … Read more

Effect of declared and undeclared variables

Declared and undeclared global variables The mechanism for storing and accessing them is the same, but JavaScript treats them differently in some cases based on the value of the configurable attribute (described below). In regular usage, they should behave the same. Both exist in the global object Below are some comparisons of declared and undeclared … Read more

Is it possible only to declare a variable without assigning any value in Python?

Why not just do this: var = None Python is dynamic, so you don’t need to declare things; they exist automatically in the first scope where they’re assigned. So, all you need is a regular old assignment statement as above. This is nice, because you’ll never end up with an uninitialized variable. But be careful … Read more

Why is initialization of a new variable by itself valid? [duplicate]

It’s syntactically valid, since the variable’s point of declaration comes before its initialiser, and the name is available anywhere after that point. This allows less dodgy initialisations like void *p = &p; which legitimately uses the name (but not the value) of the variable being initialised. It’s behaviourally invalid, since using the value of an … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)