osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can global variable be passed into Python function?


Steven D'Aprano <steve+comp.lang.python at pearwood.info>:

> The big difference is that in "fixed location" languages, it makes
> sense to talk about the address of a *variable*.

The address could be a symbol, too.

The Python statement

   xyz = 3

places a number in the address "xyz".

You can read the value from the address "xyz" with

   locals()["xyz"]


Marko