Pythons id() function and names

Sdílet
Vložit
  • čas přidán 28. 08. 2024
  • Looks at another model that helps explain what is returned by the Python id() function. It also explains why Python is often said to have names and not variables.

Komentáře • 11

  • @jvsnyc
    @jvsnyc Před 3 lety

    Python has gotten so much bigger from the early times I (barely) looked at it as we weren't using it at work, and it was just a small, simple language with indentation that changed the meaning of code. I did love the idea that "There is always only one obvious, best way to do most things." As it has evolved, some of that has gone out the window, it seems. In particular, there are now countless ways to format strings (I think I counted six), and a number of other options where before there weren't. On the other hand, I do enjoy seeing your videos, with your calm, pleasant, cheerful voice explaining lots of different useful bits of Python all over the place. Some of these basic videos have me learning only one or two small but nice new things on topics I'd cursorily looked at previously, but it is still worth it. Cheers.

    • @johnphilipjones
      @johnphilipjones  Před 3 lety

      As you say it's certainly come a long way. It still has the pleasant to use syntax and basic structures. However it's strength is now the extensive range of modules that can be imported.
      Best wishes
      Phil

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

    another impeccable explanation

  • @freddiememer
    @freddiememer Před 10 lety

    Very useful, Phil. As an ex-CCCU student, your videos were the best part of the learning experience for me. Unfortunately (for us, at least), you retired when we were being taught third-year Operating Systems. I certainly could have used your animations and videos then; that's for sure.
    Aside, I would really like to see how pointers/references work in C/C++ using the models you showed here over the two parts. This video certainly aided my understanding, but given this is Python, I'm not sure how much of it can be related to C/C++.

    • @johnphilipjones
      @johnphilipjones  Před 10 lety +1

      Hello Jimmy, Thank you for your kind words (I have just added you to my Google + circle). I cannot comment on C++ but for C a variable can be accessed by its variable name it can also be accessed by its address. C has pointers and these do hold the address of the variables address. The reason for this is C started as a 'better way' to do machine code and kept close to actual pointers to addresses as they were done in machine code. However, I have not wrote a C program for a number of years so things may have changed. Best wishes Phil

  • @anataeb7103
    @anataeb7103 Před 7 lety

    Hello, and thank you very much for the fantastic explanation but I have a question. if the value type was changed from int to float will be assigned to the same id or will change

  • @vidyakileri3548
    @vidyakileri3548 Před 4 lety

    Can we assign Id number to a value

    • @johnphilipjones
      @johnphilipjones  Před 4 lety

      No. When a variable is created its content holds the value. The id is the address of the location of the content. Best wishes Phil

  • @willcheung7041
    @willcheung7041 Před 4 lety

    when you assign 1000 to the a and b instead of 7, you will delete this video

    • @johnphilipjones
      @johnphilipjones  Před 4 lety

      It behaves differently when it is in the interactive mode. Save the program in a .py file and run it.
      Best wishes
      Phil