#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2015
    Posts
    2
    Rep Power
    0

    Variable vs. Object


    In Pythonís assignment statements, why is "base" in the statement:

    >>base = 10

    a variable and not an object? I thought base would be an object? What distinguishes a variable from an object in this case?

    Comments on this post

    • codergeek42 agrees
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,975
    Rep Power
    510
    The assignment names the object and retains that assignment for later use. Retention prevents the object from being garbage collected as long as the name remains in scope.

    >>> 10 .__mul__(82)
    820
    >>> dir(10)
    ...

    Comments on this post

    • codergeek42 agrees : Well said.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2015
    Posts
    2
    Rep Power
    0
    Great, thank you.

IMN logo majestic logo threadwatch logo seochat tools logo