Python Binding a Name to an Object

Sdílet
Vložit
  • čas přidán 28. 08. 2024
  • Describes how Python does not have an assignment statement in the 'traditional sense' of its meaning. Instead it has names that are bound to an object. This video uses two programs and a model animation to help explain the Python mechanism for assigning when dealing with immutable integers.

Komentáře • 17

  • @boa2145
    @boa2145 Před rokem +1

    Very interesting video about "binding a name to an object". Excellent!

  • @kenmeyer100
    @kenmeyer100 Před 6 lety +4

    beautifully explained!

  • @srinidhiskanda754
    @srinidhiskanda754 Před 7 lety +1

    thank you sir, i just want to clarify one thing x = 2 is an object of class integer generally we follow traditional approach to create instance of class like this x = IntegerClass() then we assign x = 2. so here actually we directly assign value x = 2. so both are same right.

    • @johnphilipjones
      @johnphilipjones  Před 7 lety +2

      x = 2 does indeed create an integer object. it is usual to describe this as implied creation.

  • @vengtCent
    @vengtCent Před 5 lety +1

    great explanation!

  • @adiy77
    @adiy77 Před 7 lety +2

    Excellent!! thank you

  • @sumitborhade1883
    @sumitborhade1883 Před 5 lety +1

    ayy thanx a lot for simplifying it so much!

  • @XieQiu
    @XieQiu Před 9 lety +3

    helpful!

  • @robertbrooks4529
    @robertbrooks4529 Před 10 lety +2

    Thank you!
    bob

  • @dilshodrahmatov3058
    @dilshodrahmatov3058 Před 6 lety

    From this video I understood that in Python use to say "Binding" instead of "Box". Am I right?

    • @johnphilipjones
      @johnphilipjones  Před 6 lety +2

      In Python a variable is a name bound to an instance of an object and the instance has the type.
      Best wishes
      Phil

  • @kravec.miroslav
    @kravec.miroslav Před 9 lety

    So,... in other words: Everything is box, but the box doesn't contain value, but the pointer to an object?

    • @johnphilipjones
      @johnphilipjones  Před 9 lety

      ***** Yes but in Python it is usual to talk about binding names to objects

    • @kravec.miroslav
      @kravec.miroslav Před 9 lety

      John Philip Jones what about properties? ... consider this:
      x = getSomeObject()
      y = x
      y.a = 5
      you don't only bind name 'y.a' to object '5', because name 'x.a' has the same value... How should I understand that?
      Thanks :)

    • @johnphilipjones
      @johnphilipjones  Před 9 lety +5

      ***** The first line is not Python but lets assume that you mean x is bound to an object after the first line. Then after y = x BOTH x and y are bound to the same object. y.a sets an attribute of this object so x.a and y.a refer to the same 'thing'