1

I understand that in Python you don't need to "declare" variables because it is dynamic. However I was wondering what was the correct way of saying it:

  1. "Assign a variable"
  2. "Define a variable"

This is just out of curiosity, but it also would be nice to understand it for documentation purposes.

Are they the same? If they are interchangeable, What is the preferred way?

7
  • 6
    In Python, the correct way is really to say 'Bind a value to a name'. Commented May 13, 2014 at 16:04
  • 1
    Bind a value to name. Commented May 13, 2014 at 16:04
  • 2
    Please don't answer questions in comments. Commented May 13, 2014 at 16:06
  • 1
    python.net/~goodger/projects/pycon/2007/idiomatic/… Commented May 13, 2014 at 16:07
  • 5
    @ValekHalfHeart: These are not complete answers, nor is the question necessarily answerable in its current form, within the constraints of Stack Overflow. Commented May 13, 2014 at 16:07

1 Answer 1

1

In Python, you bind a "name" to an object.

From https://docs.python.org/2/reference/executionmodel.html:

"Names refer to objects. Names are introduced by name binding operations. Each occurrence of a name in the program text refers to the binding of that name established in the innermost function block containing the use."

Also, you may wish to see visualization like this, to make things more clear.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.