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

Can global variable be passed into Python function?

On 2/21/14 9:47 PM, Dennis Lee Bieber wrote:
> On Fri, 21 Feb 2014 09:59:17 -0800, Travis Griggs <travisgriggs at gmail.com>
> declaimed the following:
>> 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.
> 	If one is coming from the world where "variable" means "name
> identifying a fixed location in memory" then Python does not have
> "variables".
> 	BASIC, C, FORTRAN, COBOL, Assembly... A "variable" is synonym for an
> address [a box that holds things].
> 	Even Python's mutable types (list, dictionary, for example) do not
> follow the "fixed location" metaphor. Each cell in a list merely references
> some object, and assignment to that cell changes the reference, not the
> object.

So we agree: variables in Python work differently than they do in those 

If one is coming from the world where "variable" means "name bound to a 
value", then Python does have "variables".

       Javascript, Ruby, Lisp, Perl, PHP, Smalltalk, Lua, Julia... a 
"variable" is a name bound to a value.

Ned Batchelder, http://nedbatchelder.com