Can global variable be passed into Python function?

Travis Griggs travisgriggs at gmail.com
Fri Feb 21 12:59:17 EST 2014


On Feb 21, 2014, at 4:13 AM, Ned Batchelder <ned at nedbatchelder.com> wrote:

> Man, do I hate this idea that Python has no variables.  It has variables (names associated with values, and the values can change over the course of the program), they just don't work the same as C or Fortran variables. In fact, they work exactly the same as Javascript or Ruby variables.

Thank you!

+11

I get tired of the “Python doesn’t have variables” line.

What makes Python variables/bindings/references/aliases/namedvalues/slots/bucketsofstuff surprising to new arrivals from other language kingdoms, is that accessing is pragmatically implicit (walks the scope tree for you) and assignment may require explicitness. IOW, for some “variables”, you have to do something explicit to make the variable you want to refer to, vary. Some might say there is a lack of symmetry. Pros and cons.

Personally, I don’t care. It’s one of those lessons you just learn as you go.


More information about the Python-list mailing list