Understand the weirdness. How Python Passes Arguments.

Sdílet
Vložit
  • čas přidán 4. 08. 2024
  • Mutable and Immutable types makes this Python discussion very confusing. In this video we will reference a great article in Python Weekly to understand how Python Passes arguments. This Python Discussion is suitable for all levels of Python programmers and many advanced programmers may disagree with me! Join the conversation in the comments.
    📗Article Link📖
    mathspp.com/blog/pydonts/pass...
    💬Want to talk to me and other programmers?📞
    Join our discord: / discord
    🎓Contents of the Video🎓
    0:00 Intro
    0:31 Not by Reference or Value
    4:32 Immutable and Mutable Objects
    8:28 Pass by Assignment
  • Věda a technologie

Komentáře • 26

  • @FrozenArtStudio
    @FrozenArtStudio Před 2 lety

    such a great explanation!
    glad I set a notification for a premiere)

  • @iraq4209
    @iraq4209 Před 2 lety

    Thx for the great content, i love what you do with games and its so entertaining. Keep it up man

  • @AllenKll
    @AllenKll Před 2 lety +4

    looks like pass by reference to me... it's just that certain objects can't be changed- which has nothing to do with how it's passed to a function, and more how assignment works in python. Still a great video! I just disagree with the conclusion.

    • @ClarityCoders
      @ClarityCoders  Před 2 lety +1

      That's the discussion I wanted to spur on actually. Python.org does use the pass by assignment terminology though see these docs. docs.python.org/3/faq/programming.html#how-do-i-write-a-function-with-output-parameters-call-by-reference

  • @tobienortje4134
    @tobienortje4134 Před 2 lety

    Excellent! was wondering about this quite a bit. 👍🏻

  • @emilyweston460
    @emilyweston460 Před 2 lety

    thanks :D excellent explanation! even on the brink of making sense for someone who started learning python 2 days ago..

  • @eranfeit
    @eranfeit Před 2 lety

    Thanks

  • @DylanMatthewTurner
    @DylanMatthewTurner Před 2 lety +2

    Before watching the video I'd say pass by value with an asterisk.
    That asterisk being that every Python variable is a pointer I think, so you're passing pointers by value, which in C would be how you pass something by reference as well to some extent.

    • @ClarityCoders
      @ClarityCoders  Před 2 lety

      Did you end up watching? Thanks for commenting!

    • @DylanMatthewTurner
      @DylanMatthewTurner Před 2 lety

      @@ClarityCoders Yeah. Just did. That was very informative. You learn something new every day!

    • @ClarityCoders
      @ClarityCoders  Před 2 lety +1

      @@DylanMatthewTurner Thanks for watching! Love the Backstreet Boys cover keep it up man.

  • @johndorian4078
    @johndorian4078 Před 2 lety

    But im assuming you can pass the id? or make a variable a global variable in python like you can other languages?

  • @zakyvids6566
    @zakyvids6566 Před 2 lety

    Can you make a python crash course

  • @PERSISTENTxMF
    @PERSISTENTxMF Před 2 lety +4

    Error: See line 41
    Line 41: (blank)

    • @ClarityCoders
      @ClarityCoders  Před 2 lety

      but I only have 30 lines!?

    • @PERSISTENTxMF
      @PERSISTENTxMF Před 2 lety

      @@ClarityCoders hah! Maybe it's line 41 of one of the modules you imported? :D

  • @freezerain
    @freezerain Před 2 lety

    Just like java I guess. I always missing in those languages an ability to control pass type like with c++ pointers. But then I remember that pass by value is practically useless

  • @theunknown4834
    @theunknown4834 Před 2 lety

    All this makes me think of how does list reference its elements?

  • @awffsletmein
    @awffsletmein Před 2 lety

    Assignment like age = 26 would not change the object anyways, it just replaces the old object with a new one. The age += 10 would be better example because it roughly translates to age.__iadd__(10) method call on the original object, possibly modifying it.

    • @ClarityCoders
      @ClarityCoders  Před 2 lety +1

      I actually show that example later but both create a new object. Sense integers are immutable!

  • @freeeshorts9063
    @freeeshorts9063 Před 2 lety

    Bro make zooba game Ai plzzzz

  • @jakelionlight3936
    @jakelionlight3936 Před 2 lety

    :) So you like the Cubs, Stephen king and your human child is an aspiring artist.
    What are the other two books?

    • @ClarityCoders
      @ClarityCoders  Před 2 lety

      Bag of Bones, The Stand are both on that self I know my two favorite books both by Stephen King.

  • @nick-oi1xf
    @nick-oi1xf Před 7 měsíci

    Try changing all your friends in the list. It won't😂.

  • @pixelbogpixxelbog2090
    @pixelbogpixxelbog2090 Před 2 lety +2

    .