Why You Shouldn't Use the Global Keyword in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ต.ค. 2024

ความคิดเห็น • 190

  • @TechWithTim
    @TechWithTim  3 ปีที่แล้ว +98

    Just to clarify... There is 100% use cases for the global keyword. I don't mean to say you should NEVER use it. My basic reasoning behind making this video is many people (especially beginners) use the global keyword all the time and with no understanding of how it works! I wanted to show in detail how it works and some of the pitfalls of using it. Hopefully you learned something :)

    • @BeardBarians
      @BeardBarians 3 ปีที่แล้ว

      Ahhh ok

    • @alicemystery5520
      @alicemystery5520 3 ปีที่แล้ว +2

      Nice, I am new to code and programming. I was completely confused about global myself. So thanks man.

    • @tonystark3399
      @tonystark3399 3 ปีที่แล้ว

      Bro I can't join twt code jam can please help me

    • @ankithabhayan324
      @ankithabhayan324 3 ปีที่แล้ว

      I understood a lot from this video, thankyou for uploading this. I think you need to upload more super-specific videos like this so people can know more than what they already know about something. cheers!

    • @victaiov
      @victaiov 3 ปีที่แล้ว

      Yeah, it is clear that if something is added to a language, it is done for a reason, but things just should not be used inappropriately. By the way, there is a topic that I do not understand why it is almost not explained on TH-cam. Why don't you try to make a video on async/await and what is the difference between this and threading or multiprocessing. It confuses many. Anyway, thank you!)

  • @manojuppala
    @manojuppala 3 ปีที่แล้ว +77

    This guy never gets tired.

    • @lodostic1015
      @lodostic1015 3 ปีที่แล้ว +1

      Dude its just a 15min video

  • @empty3657
    @empty3657 3 ปีที่แล้ว +83

    Tim: *defines a function inside a function*
    Me who didn't know you can do that: "wait that's illegal"

    • @thinboxdictator6720
      @thinboxdictator6720 3 ปีที่แล้ว +11

      I haven't seen that used much often.
      if you imagine the foo is not a function, but a class,it makes more sense,right? :)

    • @manu-singh
      @manu-singh 3 ปีที่แล้ว +1

      Actually I also got to know about it recently 😅

    • @prawnydagrate
      @prawnydagrate 3 ปีที่แล้ว +1

      Lol

    • @vk3fbab
      @vk3fbab 3 ปีที่แล้ว +3

      It's not something all languages support. Although with anonymous functions a lot of languages now support it. Python supports both named and anonymous functions.

    • @kensei4237
      @kensei4237 3 ปีที่แล้ว +1

      It’s more common in other languages

  • @richardjonesiii2856
    @richardjonesiii2856 3 ปีที่แล้ว +11

    Hey Tim! I learned a lot about context management from this during my lunch break, but a couple of things struck out to me. I understand that the 'global' keyword has its niche, but as for "why not to use it" wasn't clear. But here is what I think:
    The global keyword can be used for modifying a global variable without passing it by reference. For example, if there is a 'points' variable and I would like to add points to it (say, points + 1) using a function [add_points(points)], I would much rather reference 'points' by its location in memory, rather than creating a local copy in the function, caused by passing the variable into the function. So instead, by calling 'add_points()' and removing the argument from the function definition, I can access the 'points' variable by calling 'global points', and adding to it that way.
    It should be clear that for the scope of operation for the 'points' variable, it's used explicitly within functions to modify its value.
    What IS clear is that 'global' isn't used for creating a global variable. It's just telling the interpreter that the global keyword's argument should be referred by its global value, as opposed to creating a second variable that will be local to its scope.
    Thanks, man!

  • @schwischwi8523
    @schwischwi8523 3 ปีที่แล้ว +15

    Just when i was thinking of using this variable in my project lol

    • @abusiness8783
      @abusiness8783 3 ปีที่แล้ว +6

      It’s useful in certain situations and if you understand how it works then it should be no problem.

  • @priyanshusaraf9495
    @priyanshusaraf9495 3 ปีที่แล้ว +33

    Tim is literally the best TH-camr I have seen

    • @ayaanp
      @ayaanp 3 ปีที่แล้ว

      YES

    • @ayaanp
      @ayaanp 3 ปีที่แล้ว +5

      @Raghav Negi Bruh. All programmers TH-camrs are great, there's no competition, all programming youtubers want to work with the community and give information :)

    • @PNCNDNOB
      @PNCNDNOB 3 ปีที่แล้ว

      @@ayaanp
      💯

    • @kensei4237
      @kensei4237 3 ปีที่แล้ว

      @@ayaanp ⬆️

    • @ayaanp
      @ayaanp 3 ปีที่แล้ว +1

      @@uhmmm2110 Ok bro. Tim does a lotta tutorials, for example, the python & django one. Also, the best place to learn programming for beginners is TH-cam(at least in my experience). And, yes, all programming youtubers just want to give quality information, except for some channels like TechLead. And finally, he might want a like from Tim, but Tim is a great programming TH-camr.

  • @crystallarcade3996
    @crystallarcade3996 3 ปีที่แล้ว +7

    Welp, time to change my whole game code which has around 30 global variables, distributed in 6 different files...

  • @agentfifteen
    @agentfifteen 2 ปีที่แล้ว

    Hi, Great video. I just want to point out that you mentioning "you know it's confusing" makes it much more puzzling since I didn't find it confusing at all, but you saying that made me wonder whether I got everything right. Aside from that, I thought your explanation was excellent!

  • @subhanshareef939
    @subhanshareef939 3 ปีที่แล้ว +9

    me who use c++ literally everytime
    watching this video::: Interesting

    • @manu-singh
      @manu-singh 3 ปีที่แล้ว +1

      Exactly!!!

    • @geetarNL
      @geetarNL 3 ปีที่แล้ว +1

      Could you explain why this is interesting from a C++ perspective? I don't know C++. I do see the global variable often in robotics (and C++ is also often used in robotics) so I am curious :)

    • @geetarNL
      @geetarNL 3 ปีที่แล้ว

      @@satyajeetjena6758 ah, thanks :)

  • @Nedawor
    @Nedawor 3 ปีที่แล้ว +3

    Me three years ago wanting to pass multiple parameters to a function:
    Global variables: This looks like a job for me

  • @ElectronicsHikingandJesusTalk
    @ElectronicsHikingandJesusTalk 3 ปีที่แล้ว +3

    This is a Python tutorial, but it just helped me understand a JavaScript thing. Thank you!

  • @ThyFeinkoster
    @ThyFeinkoster 2 ปีที่แล้ว +2

    If you're just looking for an answer skip to 11:35

  • @doubleu4211
    @doubleu4211 2 ปีที่แล้ว

    i mean like if you change a lot of stuff you could store all these in an array and always pass the array and return it, but then you are confused while debugging what those values represent, so i think for large programs it is easier for a human to keep track of all the individual variables, but its of course not the "cleanest" way

  • @kychemclass5850
    @kychemclass5850 ปีที่แล้ว +2

    Tq as always Tim.
    But some of the problems you legitimately mentioned can be nullified by good variable name management. E.g. prefix all globals prefixed with 'Glob' moniker, e.g. Glob_x = ... Hence that a a global is called/modified is obvious would instantly make you consider if it's used in some imported module. I use a global boolean as an event driven trigger to break out of various loops. Simple uses of them are of course less likely to cause issues.
    Given that python supports globals, it would be nice to hear from it's scripter what they had in mind for its use.

    • @k1lluachan
      @k1lluachan ปีที่แล้ว +1

      yea this is what i got out of this video globals are just bad if you cant remember your one variable names

  • @ankithabhayan324
    @ankithabhayan324 3 ปีที่แล้ว +4

    Me who doesn't even know what global variable is: "interesting"

  • @mbmeweg293
    @mbmeweg293 3 ปีที่แล้ว +2

    Thanks man for cool videos, you great 👍)

  • @asadon1950
    @asadon1950 3 ปีที่แล้ว +3

    Just learned about this in your beginner course. The timing.

  • @abusiness8783
    @abusiness8783 3 ปีที่แล้ว +8

    I use global all the time since I typically like to initialize certain values that will be needed through the program inside a function. You definitely don’t want to mess with it unless you understand what it does and if you get confused by scopes. But other than that it is a very useful keyword

    • @luck3949
      @luck3949 ปีที่แล้ว +3

      There are definitely ways of doing it without using global. You can create an object with those variables, pass it into your function, and modify object inside that function. This way you'll achieve the same, but it will be explicit and unit-testable.

  • @adarshp6550
    @adarshp6550 3 ปีที่แล้ว +1

    Tim says not use global , pray to Odin and the slain soldiers of Valhalla you don't use it

  • @firelagstats
    @firelagstats 3 ปีที่แล้ว +6

    Me who uses R: "Crazy how Python works aye"

    • @dwartenb89
      @dwartenb89 3 ปีที่แล้ว +3

      No one:
      Absolutely no one:
      R: let’s start index at 1

    • @firelagstats
      @firelagstats 3 ปีที่แล้ว

      @@dwartenb89 hahaha it took me so long to get used to that, fkn R and Matlab 🤣

    • @rc8s
      @rc8s ปีที่แล้ว

      @@dwartenb89 Lua does that too

  • @sumanmitra202
    @sumanmitra202 3 ปีที่แล้ว +4

    Damn it.. i just used global variable in my voice assistant to do some automation 😂

    • @BeardBarians
      @BeardBarians 3 ปีที่แล้ว

      lol I've used it lots in my voice assistant - gotta change it now I guess

    • @sumanmitra202
      @sumanmitra202 3 ปีที่แล้ว +1

      @@BeardBarians 😂 making the variable unique will do the job why waste time rewriting better create something else😀

    • @BeardBarians
      @BeardBarians 3 ปีที่แล้ว

      @@sumanmitra202 lol 😂 - let's just forget variables altogher, it's not like we need them right?....

  • @carlabest1257
    @carlabest1257 3 ปีที่แล้ว +2

    Hey Tim, maybe you should explain that Python has no global variables. Python has module level scoope, but the variables at the module level are not global in any sense of the word. Scoping rules are very misleading and usually quite misunderstood. Examples usually are so simplistic that they do not resemble anything in reality. I know you can do better,...

    • @grawss
      @grawss ปีที่แล้ว

      This helped me, thank you.

  • @parthgupta4850
    @parthgupta4850 3 ปีที่แล้ว +2

    thanks it is one of the biggest confusion among the python coders

  • @mikesmith6838
    @mikesmith6838 2 ปีที่แล้ว +1

    One of the few cases where Python got it wrong. I really wish this wasn't like this. C++, and other languages, do variables much better.

    • @rantalbott6963
      @rantalbott6963 2 ปีที่แล้ว

      "better" for *what* though? There's a "horses for courses" aspect to this: strictly typed languages are better for complex/mission-critical programs, because they catch a lot of common errors at compile time. The extra effort of having to declare absolutely everything pays off. Untyped ones are usually better for short scripts: fewer places for typos and inappropriate variable reuses to hide, so declarations become an expense with poor ROI.
      I agree that Python could have done it better: I think there shouldn't be "automatic" inheritance. And only one "global" context. If you're inheriting from a parent, declare it as "from_parent xx" or somesuch.

  • @BeardBarians
    @BeardBarians 3 ปีที่แล้ว +3

    Ummm so I use multithreading - how else can I change a value in a function from a different function (they're running at the same time)

    • @aidendoig4542
      @aidendoig4542 3 ปีที่แล้ว +2

      use a class, and have the two functions(now methods) inside the class, you will be able to manipulate any of the class variables from within any methods

    • @BeardBarians
      @BeardBarians 3 ปีที่แล้ว +1

      @@aidendoig4542 ahh so I use self.variable for the variable - that could actually work thanks 🙃

    • @mastershooter64
      @mastershooter64 3 ปีที่แล้ว +1

      wait what's the difference between multithreading and multiprocessing? a thread is just like a virtual cpu core right? and multiprocessing uses actual cpu cores? does multiprocessing and multithreading work like parallel processing in a gpu? or is everything I said totally wrong?

    • @BeardBarians
      @BeardBarians 3 ปีที่แล้ว

      @@mastershooter64 Ummmm - I think that threading just looks like it, multiprocessing actually is, but I found threading s lot easier and had some problems with multiprocessing (which I can't remember now)

  • @richardwhalen1859
    @richardwhalen1859 ปีที่แล้ว

    Great demo. Thanks

  • @karldamus5124
    @karldamus5124 3 ปีที่แล้ว +2

    I use the global keyword all the time. It's useful and doesn't break anything if you name things appropiately.

    • @k1lluachan
      @k1lluachan ปีที่แล้ว

      yea this is what i got out of this video globals are just bad if you cant remember your one variable names

  • @m12652
    @m12652 3 ปีที่แล้ว

    Lol 11:55 onwards for a couple of minutes... since when is making a copy of a function in another file “re-using” a function. The great thing about functions is you have one copy in one place and re-use the one version. If you want it to be portable then stick it in a library where it’s nice and safe and unlikely to produce unexpected side effects. Globals are perfectly safe if you use them appropriately. Importantly... don’t use variable names that are likely to overlap. Variables names like x and y should be used locally only, inside loops for example.

  • @johnnyjunior963
    @johnnyjunior963 ปีที่แล้ว +1

    Thanks Tim I watched another video before and read a article but I was still a bit confused, this video was perfect for a beginner like me and I’m sure I’ll still get a ton of value from all your videos all the way up to mastery👏🏽🔥 you gained a student and a fan

  • @whathuh6965
    @whathuh6965 3 หลายเดือนก่อน

    Global Variables create so many issues especially in larger programs, hence don't use them at all if possible.

  • @parker5791
    @parker5791 3 ปีที่แล้ว +1

    Tim, great video! I remember when u discouraged the use of Global variables in your hangman pygame. That hangman game was actually my first ever python project and I have since started developing a small pygame mini game collection, I’ve been trying to figure it out for a while now how to integrate the hangman code into the program. I’d love if you made a small follow up explaining how to make the game run, and resettable to play multiple times with something like a menu, I know you teased it in the video but I cannot figure it out haha

  • @ehraz786
    @ehraz786 หลายเดือนก่อน

    Nothing confusing in it, the global variable is often useful when you have multiple function performing multiple operation and you have to keep updating the variable accordingly.

  • @SimonLam2024
    @SimonLam2024 3 ปีที่แล้ว

    Good point. Thanks!

  • @TechWithSabri
    @TechWithSabri 3 ปีที่แล้ว +1

    Thanks Tim for your time.
    hope you can make a video about how "constractor & this keyword " works and their importance in python.
    Thanks again keep going .

  • @subarnodatta2181
    @subarnodatta2181 3 ปีที่แล้ว +1

    The video was really helpful. Thank you. If possible please bring a series on react native and node js. It is confusing. Love from India.

  • @kenhaley4
    @kenhaley4 3 ปีที่แล้ว

    Interesting discovery (not covered here):
    x = 7
    def foo():
    x = 5
    def bar():
    global x
    x = 3
    print ("in bar, x(defined as global) =", x)
    bar()
    print ("in foo, x =", x)
    print ("outside, x =", x)
    RESULTS:
    in bar, x(defined as global) = 3
    in foo, x = 5
    outside, x = 3
    Note that declaring global x inside bar() did NOT make the x in foo() global. Only the x outside was affected by the assignment in bar().

  • @JAlpha7
    @JAlpha7 2 ปีที่แล้ว

    Great explanation the video was very helpful I learned alot from it

  • @tobeypeters
    @tobeypeters 2 ปีที่แล้ว

    You are right. But, I have a script where I keep track of an ID and I don't want to pass in that ID to the ton of methods. At first, I used the global keyword. But, now I use a dumb hack, which I call a hack, where I use a mutable type list[int] ... This hack saves me from having to pass in this ID to 13 / 14 procedures and having to return the updated ID. Also, a few of these methods update the value in the middle of the function. Could I use global()['whatever'] ... maybe ... and I might.

  • @kenhaley4
    @kenhaley4 3 ปีที่แล้ว

    I agree that 'global' should be avoided. But I wouldn't go so far as to say it should never be used.
    Why global should be avoided: (1) All the reasons mentioned by Tim are true. (2) 'global' breaks the rules of Functional Programming, where every function must always return the same result when called with the same arguments--i.e., no side effects.
    HOWEVER: Sometimes you write functions to refactor code because it's growing and getting out of control. Also, most programmers seldom use nested functions (if they even know about them). And, I think it should be stressed that functions should not be called from outside the current program, unless the current program is intended to be used as a library. Otherwise, if the current program is deleted or its functions are modified in the future, it could break other programs using those functions. (I would say this is even more important that using 'global'.)
    So, if you know your function is strictly limited to the current program, and its purpose is to facilitate readability of complex code, then using 'global' is probably acceptable, as the alternative (functions defined with long parameter lists) can quickly become unwieldy and error-prone. Of course, the best practice would be to refactor the program to avoid both 'global' and long parameter lists. Packaging data in a container (class, dict, list, etc.) might be the best approach.

  • @maaaaaass
    @maaaaaass 2 ปีที่แล้ว

    Hi Sir,
    I have a doubt plz assist me on the code :
    x=10
    def f():
    x='hello'
    print(x)
    global x
    x=x+20
    print(x)
    f()
    print(x)
    In side function f() I have a local variable with the same name of global variable, I need to print local variable value and want edit global variable and print that global variable .Please tell me is it a valid approach, kindly assist me on this.

  • @inuyashacoolieo
    @inuyashacoolieo ปีที่แล้ว

    What if I have a socket server script that I want to bury in root but I want users to be able to run a "setup" script that allows them to input IP addresses of clients and it sets them as Global variables? That way the main Socket Server script can pull in the IP addresses but still be "hidden" from sight. Would this work and would it be an acceptable use of Global?

  • @damianbutterworth2434
    @damianbutterworth2434 9 หลายเดือนก่อน

    I hated this function in the 80`s on the ZX Spectrum. :(

  • @ayaanp
    @ayaanp 3 ปีที่แล้ว +1

    4th :) I also don''t use global keyword, but I didn't know why that is...until now!

  • @FoxRedTail
    @FoxRedTail 3 ปีที่แล้ว

    I feel like an alien right now, how is it possible that it doesn't work to me? If I try to print the variable inside my function, I get "local variable 'active_soundtrack' referenced before assignment"

  • @icaryslittle6370
    @icaryslittle6370 3 ปีที่แล้ว

    Thx for clearing this up, Tim :)

  • @kir69420
    @kir69420 ปีที่แล้ว

    Damn I just got done using global with every variables in the school project 💀💀

  • @thomasedison559
    @thomasedison559 3 ปีที่แล้ว +11

    great videos!! keep going
    love your content!!

  • @rikittu
    @rikittu 3 ปีที่แล้ว +11

    What about while making something using tkinter? I made a simple calculator app but it required me to modify some value outside my function using a button.
    Even the tutorial for tkinter from freecodecamp told to use globals

    • @coderanger7708
      @coderanger7708 3 ปีที่แล้ว +2

      Exactly, if something is created, it definitely has a use for it. The problem with people is that if they think something is in some way, they have to rub their thoughts on others and the others just accept it without putting in much thought. Global is one of my favorite keywords in python. All the points that he had said in the video are false. The functions reusability depends on you, just if you don't import a function into other scripts doesn't negate the functions reusability. If you have a counter function in a script specifically created for that script, importing that is just silly. Also debugging the code even with these statements is really easy with pycharm and vscode as they have step into function where they can take you into different scripts. Tim should have done more research before coming here. He is fooling himself and thousands of people.

    • @TechWithTim
      @TechWithTim  3 ปีที่แล้ว +17

      Hey code ranger! Totally understand your comment and appreciate it. Maybe I should have looked into the tkinter example, wasn’t aware that global was used in an official tutorial. The point of this video was really more for beginners that use the global keyword all the time, rather than learning the other and usually better ways to do things. Global definitely has a use but I want people that use it to understand exactly how it works and why they’re using it :)

    • @tamasfodor2312
      @tamasfodor2312 3 ปีที่แล้ว +4

      To be honest you can avoid using global variables there also just build your calculator app with class instead just using functions it will make it better
      Also if you want to build a bigger tk inter program you will need to use classes anyway so why not start early it is a better practice

    • @rachitq1185
      @rachitq1185 3 ปีที่แล้ว +1

      tkinter is an exception in this case i think, because when i was beginner in python i too made a calc using tkinter and i was forced to use global vars

    • @coderanger7708
      @coderanger7708 3 ปีที่แล้ว +1

      @@TechWithTim yeah tim, a little more research would have been great, you agree with your flaws thats why you are my favorite python youtuber. Tkinter is not the only example, therr are many instances like kivy app development. I use it when I want to particular global variable, I just don't name it x or y, I just name it in all caps then change it in global space, so even if I import that function I'll not face anymore functions.

  • @G_M1112
    @G_M1112 3 ปีที่แล้ว +1

    Hey Tim I have problem with my game. It breaks with message Process finished with exit code -1073740791 (0xC0000409)
    . What could be a problem that makes this happens?

  • @kkkk150984
    @kkkk150984 ปีที่แล้ว

    why this gives error:
    x = 6
    def aaa():
    print(x)
    x = 88
    print(x)
    aaa()

  • @alisanmocadi6762
    @alisanmocadi6762 11 หลายเดือนก่อน

    why are you using x variable multiple times , that will really confuse it more likely haha

  • @k1lluachan
    @k1lluachan ปีที่แล้ว

    yea this is what i got out of this video globals are just bad if you cant remember your one variable names

  • @hacklordmonster8780
    @hacklordmonster8780 3 ปีที่แล้ว +1

    i like the new intro

  • @idekman
    @idekman 3 ปีที่แล้ว

    watching this after I made a game that uses a billion globals

  • @misteryo2480
    @misteryo2480 3 ปีที่แล้ว +1

    Oh come on ! My friends are telling me not to use globals, and now you are also telling me not to ! Let me use my globals T_T

  • @EnglishRain
    @EnglishRain 3 ปีที่แล้ว +1

    16:00 such good advice! Great video Tim!

  • @hackzchannel7921
    @hackzchannel7921 3 ปีที่แล้ว

    You are the best guy i ever seen you have a brillian brain

  • @luck3949
    @luck3949 ปีที่แล้ว

    What to do instead:
    1. Closures
    Let's say you are implementing random function. Instead of doing it like
    seed = 1337
    def random():
    global seed
    seed = some_math(seed)
    return seed
    You can do this:
    def create_random_func():
    seed = 1337
    def random():
    nonlocal seed
    seed = some_math(seed)
    return seed
    return random
    random = make_random_func()
    This way you accomplished the same, without messing up with global scope. Plus you can create two instances of random() function, that don't interfere with one another, which might be helpful to test this function without changing the random state.
    2. Objects.
    Create class RNG that contains seed.
    Now use
    def random(rng):
    rng.seed = some_math(rng.seed)
    return rng.seed
    rng1 = RNG()
    number = random(rng1)
    This way you achieved all of the above + explicitness.

  • @dantonddsa
    @dantonddsa 2 ปีที่แล้ว

    Would you say that calling the globals() from a function to check on its value and then make the return changes is also bad practice?
    like in your example:
    def add_7(x):
    result = globals()['result']
    return result + 7
    result = 65
    print(add_7(result))

  • @adhamsabry6011
    @adhamsabry6011 3 ปีที่แล้ว +1

    Thank you so much Tim you have been a real source of inspiration for me

  • @thebestnerd4444
    @thebestnerd4444 3 ปีที่แล้ว

    I think this video is longer than it needed to be.

  • @angryducklinginstitution76
    @angryducklinginstitution76 3 ปีที่แล้ว

    If a person wanted to use the global keyword to ensure that they are able to define all of their variables, couldn't they just set their variables as immutable tuples instead, ensuring that the variable definition would never change within the scope of the file? That would perhaps be best. Then again, I'm a first-year software engineering student who's green as Hell and doesn't know what he's talking about - Lol. I did, however, try to override the a tuple using the global keyword, and that didn't work.

  • @shalomakolatse537
    @shalomakolatse537 3 ปีที่แล้ว +4

    Tim was really spitting bar()s on this one.

  • @Matthew-pc3zx
    @Matthew-pc3zx 2 ปีที่แล้ว

    Python is like Inception.

  • @alejandrocabrera8769
    @alejandrocabrera8769 3 ปีที่แล้ว

    does this apply to if statements?

  • @irfanhossainbhuiyanstudent3757
    @irfanhossainbhuiyanstudent3757 3 ปีที่แล้ว

    Use nonlocal instead of global.

  • @MD-vm7tv
    @MD-vm7tv 3 ปีที่แล้ว

    Hi, Brother,
    I'm a freelancer! Experienced with web scraping but I want to switch to web development. I don't have a college degree, I have a little knowledge about Django, Flask, Celery, and React.
    Should I go for Backend with Python or Frontend with React or something else? Can you consider to recommend a path for me?

  • @passord1d493
    @passord1d493 3 ปีที่แล้ว

    can you make tutorial on activatypub python

  • @mcplayer6630
    @mcplayer6630 2 ปีที่แล้ว

    pretty damn good video

  • @tonystark3399
    @tonystark3399 3 ปีที่แล้ว

    Bro I can't join twt code jam can you help me please

  • @frane5173
    @frane5173 2 ปีที่แล้ว

    It works! Thank you!

  • @sergeykapshuchenko5695
    @sergeykapshuchenko5695 3 ปีที่แล้ว

    wtf who uses globals ? xD

  • @mr_ambivalence
    @mr_ambivalence 3 ปีที่แล้ว

    But how do i avoid using global keyword even in basic click counter with tkinter GUI?

    • @mr_ambivalence
      @mr_ambivalence 3 ปีที่แล้ว

      @Saketh p you can't use incrementation in this lambda bc it gives the num new value (instead of returning it) and that leads to an error. Thanks for trying though

  • @Aristocle
    @Aristocle 3 ปีที่แล้ว

    hierarchical system that take nearest assignment if you dont set global value.

  • @Isaac-qu3wl
    @Isaac-qu3wl 2 ปีที่แล้ว

    0 good points made

  • @aquibshaikh8611
    @aquibshaikh8611 3 ปีที่แล้ว

    the person who creates your video thumbnails must be a very cool person.. !

  • @suryabhavithperugupalli7041
    @suryabhavithperugupalli7041 3 ปีที่แล้ว

    I have 2 questions how do you get the information about the code jam on discord and how do you deploy a music bot to Heroku. Because you have to use some dependices like FFMpeg that are local to your computer. Love Your videos and thank you for the support👏❤

  • @xuanchili
    @xuanchili 3 ปีที่แล้ว

    crystal clear

  • @FT4YOU
    @FT4YOU 3 ปีที่แล้ว

    speed 1.25 ;)

  • @eduard289
    @eduard289 2 ปีที่แล้ว

    thx

  • @Aivin
    @Aivin 3 ปีที่แล้ว

    Yo! I have a video suggestion, can you make a video talking about return vs global for beginners?

  • @reisaki18
    @reisaki18 3 ปีที่แล้ว

    I think global statement is useful.
    Just don't reuse or import the file.
    Use it for small projects.

  • @thewadegreen
    @thewadegreen 3 ปีที่แล้ว

    I'm surprised you didn't go into the idea that if you have a bunch of global variables that need to be modified, there's a class hiding somewhere in there, or a few. Great video though, keep up the good work, thanks for all the great tutorials!

  • @brandonfuerst2977
    @brandonfuerst2977 3 ปีที่แล้ว

    LOVE this. I handed off a program once, and it came back with a UI function accepting user inputs and assigning them to global variables which could already be referenced and assigned earlier through a different UI. It was very poor practice and introduced bugs.

  • @Sam-tg4ii
    @Sam-tg4ii ปีที่แล้ว

    Great tutorial. At 15:08, a case in which you will certainly not see the problem is if you imported the add_7 function from another script

  • @p.mousumipriyadarshini8677
    @p.mousumipriyadarshini8677 3 ปีที่แล้ว

    thanks Tim, you cleared my doubt on global variable💞

  • @belleeun
    @belleeun 3 ปีที่แล้ว

    awesome tutorial, can you make a tutorial explaining what does: '*' do ?

  • @abrarmasumabir3809
    @abrarmasumabir3809 3 ปีที่แล้ว

    bro make a video on algorithim in python plz.....

  • @lisaliang2507
    @lisaliang2507 3 ปีที่แล้ว

    It's really helpful!! Thank you

  • @lordangus77
    @lordangus77 3 ปีที่แล้ว

    IMO the issue is not about using the global keyword but a global variable

  • @masterhai4924
    @masterhai4924 3 ปีที่แล้ว

    very useful. thanks tim. have a good day

  • @rafid_zx
    @rafid_zx 3 ปีที่แล้ว

    It was a nice video, keep up the good work :thumbsup:

  • @theyoutubeaccount8499
    @theyoutubeaccount8499 3 ปีที่แล้ว

    Ay tim got a cherry mx blue keyboard finally

  • @skgujar2725
    @skgujar2725 3 ปีที่แล้ว

    Tim, please make more videos on python

  • @zafaris
    @zafaris 3 ปีที่แล้ว

    Nice video Tim! 😁👍🏽

  • @shahzaibali4911
    @shahzaibali4911 3 ปีที่แล้ว

    XD thanks was about to ask the same question in your discord

  • @rayankazi6029
    @rayankazi6029 3 ปีที่แล้ว

    Hello! came here after video was uploaded 12 seconds ago lol

  • @stephendouglas9355
    @stephendouglas9355 3 ปีที่แล้ว

    Very well explained! Thanks Tim!

  • @subarnodatta2181
    @subarnodatta2181 3 ปีที่แล้ว

    A request, Can you please bring a series on React Native. It is a bit confusing. Any way love from India.

    • @ajay2552
      @ajay2552 3 ปีที่แล้ว +1

      Yeah please

  • @devoiddude
    @devoiddude 3 ปีที่แล้ว

    Great explanation thank you!