STOP Making These Python Mistakes

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024

Комментарии • 143

  • @troyke
    @troyke Год назад +11

    Tim, as someone who has vision problems, I REALLY appreciate how you zoom the code in your IDE, so that it's easier to read! It's just ONE of the many reasons your channel is so successful! THANK YOU!

  • @BaconBitsJuice
    @BaconBitsJuice 2 года назад +36

    Ty Tim. My wife's bf has been giving me more computer privledges lately and your content has really been helping me learn a new skill!

  • @kamilherbetko5670
    @kamilherbetko5670 2 года назад +58

    9:27 is also dangerous because bare except catches BaseException objects, so it will also catch KeyboardInterruptException. This can lead to a program that can only be stopped by killing the process.

  • @kiranreddy4046
    @kiranreddy4046 2 года назад +72

    In the past everything used to fly over my head in these kinds of videos but I’m proud that i can understand and comprehend why these errors can happen while coding and I’ve faced a few scenarios that are mentioned in the video. Great stuff

  • @shreyanshughosh7241
    @shreyanshughosh7241 2 года назад +12

    I joined this channel when it have just 250k subs. From that it had a growth of 948k till date. This is just Tim's hardwork n patience which led his success. Wishing all the very best for the future buddy :)
    Well, thanx for this video too.

  • @vicb0
    @vicb0 2 года назад +25

    7:50 Instead of creating an aux array or something to store the new list while iterating, you can just iterate a slice of the list which will create a copy
    for count, value in enumerate(list[:])

    • @blackdereker4023
      @blackdereker4023 2 года назад +2

      List slice will not just iterate over the slice, it will create a copy of the list. Enumerate is a generator and won't create a copy, it will just iterate over the already created list.

    • @vicb0
      @vicb0 2 года назад

      @@blackdereker4023 yes, I know. It's exactly what I said

    • @suche_cz
      @suche_cz 2 года назад

      creating copy of that list may be inefficient

    • @jgtb0pl
      @jgtb0pl 2 года назад

      you can also use filter

  • @Robnoxious77
    @Robnoxious77 2 года назад +5

    when modifying iterables (like deleting elements selectively for example), sometimes i’ll iterate through the list backwards, so that the length of the list after a delete (in the direction i’m iterating) doesn’t actually change.

  • @gabriellopezmontesinos2951
    @gabriellopezmontesinos2951 2 года назад +3

    Maybe it's been said already in the comments, but I recommend using the try - except like this:
    try:
    blabla
    except Exception as e:
    print(e)
    That way you will directly print the error that is found at the try

    • @JGnLAU8OAWF6
      @JGnLAU8OAWF6 Год назад +1

      Even better is to do:
      try:
      ...
      except Exception:
      logging.exception()

  • @chfalcao
    @chfalcao 11 месяцев назад

    I've been programming since 1984 (yes I'm a dinosaur) and progressed on the corporate ladder up to Senior Management but keep programming as a hobby over weekends. Started learning python 5 years ago and this is the first time I finally understood WHY there's a difference between lists and sets. A pay donation is coming your way after this comment. Keep on the good work.

  • @carmelomarasco4746
    @carmelomarasco4746 Год назад +1

    Yours is one of the best youtube channel about python. Topics covered are interesting and your explanation is crystal clear. Last, but not the least: I'm not an english native speaker, but I can understand what you says without any effort, your accent and pronunciation are very clear. Thank You

  • @BlyatifulButter
    @BlyatifulButter 2 года назад +4

    At mistake #5, if you don't know what kind of exception you'll get, just write "except Exception as e:" and then print out the exception like this: print(f"An exception occurred: {str(e)}") notice the str(e) to convert the error message into a string

    • @Bruh-sp2bj
      @Bruh-sp2bj 2 года назад +2

      This is a terrible thing to do which I dont fault since the people who watch tim are mostly inexperienced coders. Printing out e gives you the __str__() of the exception it doesnt actually contain the full traceback. The error printed is basically useless since it doesnt contain debug information like line number errors or which file the error originates from. It may not even tell you what error was caught since it only passes out the string raised in the exception which may not contain the actual exception name. A better method is to use the traceback stdlib module

    • @BlyatifulButter
      @BlyatifulButter 2 года назад

      @@Bruh-sp2bj yeah, that method definitely works way better but I rarely use it in my projects (because I would just remove the try except block to see the full error anyway, I'm stupid), I only preprogram what to do if it caught a certain exception and just print out the rest for me to fix later on.

  • @imaginecloudsxo7987
    @imaginecloudsxo7987 2 года назад +8

    Hey Tim, could you maybe make a video on Argparse and how to create Subparsers and how you could use them in the command line interface? We just had an assignment with Argparse and I am not quite sure if I actually understand what I am doing when working with Argparse. Thanks in advance!!

    • @0xtz_
      @0xtz_ 2 года назад +4

      U can check the docs it's very simple and anyone can understand it 👍

    • @TechCowboy
      @TechCowboy 2 года назад +2

      @@0xtz_ If she's asking the question, then not everyone can understand it. If you're not going to help her, don't commment.

    • @miguelguthridge
      @miguelguthridge 2 года назад +2

      I'd also love to see this one - argparse isn't exactly the simplest thing ever, and although documentation exists for it, reading documentation can be very difficult, especially for people with ADHD and other attention span disorders.

  • @jti107
    @jti107 2 года назад +1

    i bought the programming expert course couple weeks ago and just finished it. i recommend it to for new programmers and experienced programmers new to python. you can find similar material on youtube for free but the site organization, the section quizzes/programming exercises and gamification really makes it worth it. there is also a section on Go programming language which I havent done but looks interesting.

  • @sugumarprabhakaran
    @sugumarprabhakaran 2 года назад +7

    Very nice video. This is exactly the type of content that I need since I'm an intermediate-ish programmer and just want to keep getting better.
    No benefit in going through basics over and over for people stuck at my level.
    Thank you Tim!

  • @TheDuerden
    @TheDuerden 2 года назад +1

    I believe you can create a tuple of exception errors - rather than writing a block for each of them, and then use e as you described to provide which one of them was caught. Useful if you don't want long code.

  • @empmachine
    @empmachine 8 месяцев назад

    Just FYI (since I liked the vid and felt you might care to know), some cultures see an asymmetrical mouth/cheek pull (like if you use your mouth muscles to pull one side of your mouth towards your ear) as a gesture of contempt.

  • @ManishBhatiaLDN
    @ManishBhatiaLDN Год назад

    Hi Tim - im an experienced developer, paused at 3:41 will watch the rest of the video, but for the FIRST mistake - it would be good to give direction to viewers how to correct it.
    The way I do it and think is one of the ways to avoid name shadowing is to add a. "underscore" before the builtin function your shadowing....
    So fix is to do something like this "id" --> "_id"

  • @Dbrano3
    @Dbrano3 2 года назад +1

    Another one, is using the print function instead of the logging function for debugging and general logging of information

  • @indiraparajuli9715
    @indiraparajuli9715 2 года назад +2

    Tim brother always on 🔥🔥.
    while Everyday:
    Quality content++;

  • @aikimark1955
    @aikimark1955 2 года назад +1

    My rule of thumb on changing lists during iteration is to iterate the list from the end to the beginning.

  • @pravachanpatra4012
    @pravachanpatra4012 2 года назад +6

    Hey Tim can you make Django social media clone or chat app. Or a program in Pygame that can encrypt images or sound?

  • @akira_asahi
    @akira_asahi Год назад

    Thank you for the video. I am grateful for your time and contribution. Kind regards, Akira.

  • @imtiazahmad7826
    @imtiazahmad7826 2 года назад +2

    I use backward elimination for 6:51

  • @PoojaDutt
    @PoojaDutt 2 года назад +2

    I really want to start using Python soon .. I’m just dreading the indentation aspect 😅 but I’ve heard it can be a very powerful language. Thanks for this video!

    • @SACHINYadav-ms2ck
      @SACHINYadav-ms2ck 2 года назад +1

      Lets learn together

    • @ViktorHilmer
      @ViktorHilmer 2 года назад +6

      @@SACHINYadav-ms2ck my man is down bad

    • @BaconBitsJuice
      @BaconBitsJuice 2 года назад +1

      @@ViktorHilmer lmao

    • @chagsssss
      @chagsssss 2 года назад +1

      Don't worry about the indentation part, I have been doing Python for 4 months and it hasn't been a problem.

    • @miguelguthridge
      @miguelguthridge 2 года назад

      In most programming languages you'll be indenting things anyway (or at least if you aren't then that's awful code style) - most of my students have no problems with Python's indentation for that reason.

  • @seanmackenziedataengineering
    @seanmackenziedataengineering 2 года назад +4

    Cool video! These are great points. Usually, if I _have_ to do #3, I will typically iterate backward through the list. Then you can pop anytime and it doesn't affect the outcome.

    • @quitchiboo
      @quitchiboo 2 года назад +1

      Pretty clever.

    • @DrDeuteron
      @DrDeuteron 2 года назад

      @@quitchiboo right, and 'clever' is not a compliment in python.

    • @quitchiboo
      @quitchiboo 2 года назад

      @@DrDeuteron You'll have to elaborate.

    • @DrDeuteron
      @DrDeuteron 2 года назад

      @@quitchiboo clever is unpythonic, as it affects readability:
      >>>import this

    • @quitchiboo
      @quitchiboo 2 года назад

      @@DrDeuteron Kind of a very broad, unspecific statement. I get what you're saying though. Now given this particular example, readability is not at all impaired, it uses a built-in and avoids a problem quite efficiently, wouldn't that be very pythonic?

  • @anjaan480
    @anjaan480 2 года назад +2

    Whats the extension you use to show the errors inline where it occurs?

  • @tomasreyestellez485
    @tomasreyestellez485 Год назад

    Excelent, your resume of common mistakes for new Python users

  • @Wallee580
    @Wallee580 2 года назад +1

    Hiya Tim!
    I have conflicting feelings with that last one as it is useful to use global variables when dealing with threading or multiprocessing.
    Here is some quick code I made up for you as an example of what I would think is a global variable done correctly
    # Import thread from threading using multiprocessing does not seem to work well
    from threading import Thread
    # Import system from os
    from os import system
    # Define a function to wait for the user to press enter
    def waitForInput():
    # Call the global variable run
    global run
    # Ask for input
    input()
    # Set run to False
    run = False
    # Return
    return
    # Define run as Truee
    run = True
    # Setup the wait process
    wait = Thread(target=waitForInput)
    # Start the wait process
    wait.start()
    # Repeat forever
    while True:
    # Do some very important stuffs/calculations
    print("\033[7;37;40mSubscribe to Tech With Tim :p\033[0;37;40m")
    # Use a break method to prevent an extra print, this uses more time each loop though
    if run == False:
    break
    # Close the wait process
    wait.join()
    # Clear the screen
    system("cls") # Use clear for Linux
    Okay that was a bit more than a few lines but that is because I tend to comment stuffs for beginners to have an easier time to read.
    Tell me if there is a way to make this not use a global variable and I will be a very happy programmer :p
    Thanks for reading, mataatode :')

  • @CarlFritz24
    @CarlFritz24 Год назад

    Is there a LIST to avoid those mistakes, Tim ? Also a LIST of built-in Functions would be appreciated.

  • @xzax-mverse7430
    @xzax-mverse7430 2 года назад +1

    Good info, I found the data structure information to be useful. I've got to say I was a bit annoyed in the name shadowing when you revealed "id" to be a built-in function and therefore a problem under this subject. I thought to myself, "be patient maybe there is a good explanation". So, I looked up the method.
    I'm still a bit annoyed they decided to use such a common and useful parameter name as a built-in function... If everything is an object with an id it seems much more logical to just leave it within the structure of [object].system_id. Zero need for a built-in function at the global system level. It's a small thing but a bit annoying, certainly not your fault. If there is an argument for this the global method should at least be called get_id() to conform with standards.
    Further this is where it seems the culture of only "snake_case" comes to bite because the language could easily differentiate global functions with "ProperCase" (GetId()) and then there wouldn't be naming collisions with parameters at all. Makes you wonder about how all this was really decided and if there shouldn't be an offshoot.
    When I see this, I feel like a lot of stubborn people were involved in the making of this language's norms(scientists and programmers perhaps lol).
    I'm sure I'm preaching to the choir, but this video posting is where I am right now, so I'm not going to go find the standards committee to make a formal change request lol.
    So far Python seems like a modern language with some really old hang-ups it needs to shed. I'm trying to keep my mind pried open though even still.

  • @NishantCosmos
    @NishantCosmos 2 года назад +1

    5:10 why not just
    if lst:
    pass

  • @helissonoliveira3807
    @helissonoliveira3807 2 года назад

    5:23 instead of using lst=None, we could make
    def mul..(lst=[]):
    lst_aux = lst.copy()
    ...

    • @landsgevaer
      @landsgevaer 2 года назад

      Works in principle, but way too error prone because you still have access to the mutable empty list. People forget why the copy is there, so stick with an *immutable* sentinel value like None, (or zero, if need be, or similar). You cannot accidentally overwrite or modify a None.

  • @luiselsen7486
    @luiselsen7486 2 года назад

    I was actually surprised i didn't make these errors the only one i make is using global for easy tkinter programs where i don't give a shit about how it's written

  • @ABMA79
    @ABMA79 2 года назад

    I have a question... do you have a series of lessons about python and how to use each feature? You seem like an expert in python and it would be great to learn from someone with such great understanding.
    Please try to provide a series of lessons in python boosted with examples for illustration purposes.

    • @TechWithTim
      @TechWithTim  2 года назад +1

      I do! But you can also learn everything you need from programmingexpert.io ;)

    • @ABMA79
      @ABMA79 2 года назад

      @@TechWithTim Thanks for the reply.

  • @RomaRapoport
    @RomaRapoport 2 года назад

    a naked except is really case dependent from my experience and logic dependent

  • @Lunolux
    @Lunolux 2 года назад

    great video, learning many think about python again, thx

  • @karlbooklover
    @karlbooklover 2 года назад

    I catch exceptions like this, let's you catch them all and print them out
    except Exception as ex:
    print(ex)

  • @mgtan8900
    @mgtan8900 2 года назад

    Hey Tim, good stuff as always. Thanks for the advise. May I know do you have any tutorials on Tkinter to build GUI? I love to learn from you.

  • @JayTailor45
    @JayTailor45 Год назад

    Thanks Tim!

  • @Talwyn_Wize
    @Talwyn_Wize 2 года назад +2

    I often hear the warning about using a global variable, but not what alternatives to use. Being a complete beginner, I've been stuck on that a few times. Any experiences to share?

    • @chrysos
      @chrysos 2 года назад +1

      v = 3
      def do(x):
      return x+2
      v = do(v)
      # Conclusion:
      # v was modified without using global (v is now 5)

    • @piggy3595
      @piggy3595 2 года назад

      @@chrysos What about if you have a data structure that each method needs to alter? "Don't use global variables" sounds like a dumb "trick" because global variables are needed...

    • @DrDeuteron
      @DrDeuteron 2 года назад

      @@piggy3595 the only thing a method should modify are attributes of the class/instance to which it belongs. So put the data structure in the class and have at it.

    • @piggy3595
      @piggy3595 2 года назад

      @@DrDeuteron right, so how can multiple methods affect the same variable? global variables

  • @반안
    @반안 2 года назад

    thanks for useful tips.

  • @pieter5466
    @pieter5466 Год назад

    7:47 do you describe examples of such a list modification anywhere?

  • @harinivadarevu770
    @harinivadarevu770 2 года назад

    very useful one for python developers !

  • @amirilifee
    @amirilifee 2 года назад

    Thanks much for helping)) Keep it up✊✊✊

  • @machineteacher3573
    @machineteacher3573 2 года назад

    Tim I love you so much and I watch your videos everyday and I'm very excited for you to reach 1m subs. I wanted to suggest that you upload serieses of video for one topic (playlist) because when learning how to code people tend to get attracted to playlists because they are rich of information and demonstrative.

    • @TechWithTim
      @TechWithTim  2 года назад

      Great idea! I have a bunch but will definitely consider making more

  • @Th3BlackLotus
    @Th3BlackLotus 2 года назад

    One dumb mistake I make all the time is asking for input and then not making the corresponding "if input == x" statement match it. Like if I do:
    xyz = input ()
    If input == 1
    Instead of doing:
    xyz = int(input())

  • @usamashami11
    @usamashami11 2 года назад

    Insightful! You are inspiring!

  • @tecart3280
    @tecart3280 2 года назад

    At mistake 2 i tried running this code and it lead to the same behavior
    class h:
    def __init__(self):
    self.val = 0
    def f(g=h()):
    g.val+=1
    return g.val
    print(f())
    print(f())
    I think Reference type default parameters does not get created every time

    • @blackdereker4023
      @blackdereker4023 2 года назад

      You're right. The class will instantiate once when the function is defined.

    • @DrDeuteron
      @DrDeuteron 2 года назад

      the mistake here is making and instance attribute, 'val', that can't be instantiated. Default to a class attribute and automatically create and instance attribute when accesed.
      (though f is a sin for modifying an instance variable outside an "h" method)
      >>> class h:
      ... val = 0
      ...
      >>> def f(g=h()):
      ... g.val+=1
      ... return g.val
      ...
      >>> f()
      1
      >>> f()
      2
      >>> f()
      3
      >>> h.val
      0
      >>>

  • @michaelmeux4137
    @michaelmeux4137 2 года назад

    The raw input for some reason doesn't make sense to me. Currently in online school learning code but the course relies on googling to teach the students which is extremely frustrating. Do you have any information or sample code to read through? The primary program we're using is JES and trying to find anything for example without paying for it is difficult.

  • @davidconiglio7577
    @davidconiglio7577 Год назад

    Tim ,I am confused. Try to type what codes are made and get lots of mistakes ,try deleting, and can not .how do I get line numbers ?

  • @Iron770
    @Iron770 2 года назад

    I've run into mutable default parameters before.... Now i know!

  • @jacko314
    @jacko314 2 года назад

    aren't set and dict O(log(n))?

  • @nosharing-sf2mk
    @nosharing-sf2mk Год назад +1

    these are insane vids

  • @carlosvazquez2710
    @carlosvazquez2710 2 года назад +1

    Nice video

  • @sarahz2255
    @sarahz2255 2 года назад

    Hi Tim, I am interested in your course but have a quick question , I have 0 coding experience , if I finished your course will I be job ready ? Thank you

    • @TechWithTim
      @TechWithTim  2 года назад

      Yes! You will be at a junior software engineering level

    • @sarahz2255
      @sarahz2255 2 года назад

      @@TechWithTim thank you for your reply !:D

  • @aicode2304
    @aicode2304 2 года назад

    I don't know if anyone else has the same problem, but I'm currently learning oop, and it feels like everything i do with oop, I'm just copying procedural programming. And I've heard the quote, "the best function is the function with no parameters" but i use a ton of parameters because i don't know what else to do with them. I hope this isn't too confusing.

    • @Bruh-sp2bj
      @Bruh-sp2bj 2 года назад

      then you dont understand the purpose of OOP. Pick the right design paradigm for your projects.

    • @aicode2304
      @aicode2304 2 года назад

      @@Bruh-sp2bj so not all projects should have oop?

    • @piggy3595
      @piggy3595 2 года назад

      @@aicode2304 I mean in java for example, your methods can alter global variables/static variables using the "this" keyword. But functions need parameters. I'm not sure what that quote means contextually, but a function has to take in a parameter otherwise it doesn't have any variable to do anything with (unless function is part of a class, in which case it can use the "this" keyword). Perhaps an example of a function you think needs less parameters could help?

    • @Bruh-sp2bj
      @Bruh-sp2bj 2 года назад

      @@aicode2304 obviously. There exist so many paradigms out there OOP shouldnt always be the first thing you use sometimes its not even a good one

    • @DrDeuteron
      @DrDeuteron 2 года назад

      I think all functions should be pure: the result is always the same for the same input, so a parameterless function is useless. Many beginners' OOP is just a script in a class. Tips to avoid that:
      > A class has one reason to change (see: SRP)
      > don't do work in dunder init (it's very tempting. Replace with a classmethod helper that does
      the work and then returns the instance)
      > make the entire instance in dunder init (pass in all parameters once, no setting later).
      > only modify instance attributes in its own class methods
      > avoid functions (on your classes): A class should provide all the methods its instances need.
      > a method should do one thing (or farm out sub tasks to lesser methods)....e.g., don't have a:
      def do_all(self):....

  • @Mark-zi6nt
    @Mark-zi6nt 2 года назад

    Non-video related question.
    If i wanted to stream my pc screen that's working at home to another pc or mobile device, how would i do that?
    I don't want to constantly get behind my pc and it would my life easier if i was able to monitor stuff and control it via just my phone.

  • @chfalcao
    @chfalcao 11 месяцев назад

    Thanks!

  • @Pcoxproductions
    @Pcoxproductions 2 года назад

    Is there a vs code extension that annotates the time operation of your code like GIT lens?

  • @q.w.e.r.t.y
    @q.w.e.r.t.y 2 года назад

    13:48 So, why is searching through a set faster than searching through a list? Is it just because sets allow no duplicates? If so, then does than mean not having duplicates makes it the same search speed. Or is it to do with the searching algorithm used?

    • @deadendjesenice
      @deadendjesenice 2 года назад +1

      To search a list, you have to loop through all of the values. Best case scenario it is the first element and it's really fast, worst case scenario it's the last element or it doesn't exist.
      Don't know for certain but a python set is probably implemented using a hastable so it does the lookup in constant time, regardless of the number of elements you want to search. So as the number of elements grows the slower it is to search it. It is also true the other way, if you are interested in for example only two elements, then searching a list would be faster, because the searching algorithm is far less complex.
      But unless you need those microseconds (the speed of a human eye blink is 100 to 400 milliseconds) the choice for looking a data structure that is used to be tested if an element is a part of should be the set, and you use a list to hold data, which you will then usually loop over it and do something with each element

  • @mohiuddinsyed1684
    @mohiuddinsyed1684 2 года назад

    Make a tutorial on raylib/pyray Please 🙏🙏🙏.
    its documentation is very confusing and not as detailed as for Eg: Pygame.
    And most tutorials out there are for C/C++

  • @dovahkiinvokul9073
    @dovahkiinvokul9073 2 года назад

    8:20 lol this happened to me today, like just 2 hours ago

  • @saurabhmahra4084
    @saurabhmahra4084 Год назад

    So I had an interview for a job in a company, and they forced me to admit that it is a bug that lists in Python gets mutated. Thank god I did not join the company.

  • @baphnie
    @baphnie Год назад

    Global variables are fine if you know what to look out for. I don't understand why everyone treats them like they're inherently broken.

    • @rantalbott6963
      @rantalbott6963 Год назад

      In a way, they are. Python doesn't require that variables be explicitly declared like many languages do. In a language like C, there's no ambiguity about whether a local or global variable is being referenced. In Python, if you don't explicitly declare a variable global, there is. If you have assignments inside if blocks, which variable gets referenced could even vary from one invocation to the next. If you're accustomed to "traditional" compiled languages, that's pretty "broken".
      Tim has done at least one "Don't use globals" video where he explains how messy this "inheritance" of variables can get. I was shocked by how easy it is for programmers to screw themselves with references to the "wrong" instantiation of variable "x" or "i". It happened to me when I was first learning Python: I had put my "parse command line options" code in a separate function, and declared the option settings globally, as I've customarily done for decades. I got puzzling results until I learned that I needed to declare them as global in the function where I used them.
      The lack of a requirement for declarations is handy if you're just writing small scripts, but it creates a risk of deploying mistakes that other languages catch and warn you about at compile time.

    • @baphnie
      @baphnie Год назад

      @@rantalbott6963 I appreciate you sharing your experience. I’ve been able to assume to date that the behavior is consistent, if not familiar. But I guess that’s not even the case. I’ll keep an eye out for this in my work!

  • @theambassadorstrail
    @theambassadorstrail Год назад

    I love the tips

  • @Betabdullah
    @Betabdullah 2 года назад

    Thanks for your videos

  • @dziurappa
    @dziurappa 2 года назад

    You have to code to make mistakes!

  • @peace-to-the-world
    @peace-to-the-world Год назад

    All built-in functions and reserved keywords MUST be named according to the following rule:
    {ReservedKeywordName_languageAcronymEnding}
    Bingo!

  • @tomgreg2008
    @tomgreg2008 2 года назад

    good vid, thanks

  • @AddisChess16985
    @AddisChess16985 2 года назад

    Nice video!

  • @natyacodes
    @natyacodes 2 года назад

    00:53 is biggest mistake ever made by someone ngl

  • @FuShi-hr4vc
    @FuShi-hr4vc Год назад

    the most wrong fail is keep to learn any libriry without learn pygame

  • @gustavojuantorena
    @gustavojuantorena 2 года назад

    This video is 🥇🥇🥇

  • @Damqq
    @Damqq 2 года назад

    About the "shadow naming" I think this is not completely true that has been spoken... When you define a shadow name you still can access original function definition by calling:
    __builtins__.foo(), eg: __builtins__.max(), __builtins__.min() or __builtins__.id().
    I think this should be adressed :)

    • @Bruh-sp2bj
      @Bruh-sp2bj 2 года назад

      no sane programmer does this. Its ugly and unpythonic. Just name your variables properly or prefix them with an underscore

    • @blackdereker4023
      @blackdereker4023 2 года назад

      It makes your code less readable.

  • @Bruh-sp2bj
    @Bruh-sp2bj 2 года назад

    I respectfully disagree with number 5, there are many valid reasons to use naked excepts and the pitfalls of naked excepts are generally overblown. Typically you want to purposefully catch exceptions before placing general excepts at the end of exception chains. However you can use general excepts for error logging and catching unseen edge cases of well tested programs while not crashing the program in an ungraceful manner. The pitfall of bare excepts can be essentially mitigated with the traceback library that can either print or obtain full traceback messages for logging without actually exiting the program. One thing I will agree on is to not use except on its own this catches anything including KeyboardInterrupt and SystemExit, its better to catch except Exception which allows SystemExit and KeyboardInterrupt calls to properly propagate. I guess the idea I want to bring across is that catching general exceptions is perfectly fine as long as you know what you are doing

  • @mnageh-bo1mm
    @mnageh-bo1mm 2 года назад

    What's the Editor Name ??????????????????????????????????????????????????????

  • @kassandrarodriguez8057
    @kassandrarodriguez8057 2 года назад

    I did mistake number 4 one time and I couldn’t figure it out to save my life. My boss had to tell me what I did wrong 😑

  • @mrolivernone4040
    @mrolivernone4040 2 года назад

    Lol i've never changed list's length while iterating through it.

  • @magicfay
    @magicfay 2 года назад

    i'm trying to be better but it's been a while since i feel stuck at the beginning

  • @sekiro_19
    @sekiro_19 2 года назад

    number 2 is poizn

  • @illegalsmirf
    @illegalsmirf 2 года назад

    The biggest mistake is using Python in the first place

  • @Grempington
    @Grempington Год назад +2

    Can safely say in all my years of writing python I never made even a single one of these mistakes, even early on.
    Source: I have never written anything in python

  • @floppitommi123
    @floppitommi123 2 года назад

    you should have posted this a year agooo

  • @datdwaa1532
    @datdwaa1532 2 года назад

    for mistake one i never have that problem cuz I name them eeeeeeeeeeeeeee and hi and bonk

  • @santiagoley6403
    @santiagoley6403 2 года назад

    19 minutes for 7 errors is too much, this should be more concise.

  • @keewinek
    @keewinek 2 года назад +1

    first mistake: You're using python.

  • @icey1111
    @icey1111 2 года назад

    first

  • @Mets_xx_Fan_01
    @Mets_xx_Fan_01 2 года назад

    magic = 200
    magic2 = 33
    magic3 = 0
    def success(dedication, persistence, passion):
    dedication += 1 # dedicate yourself
    persistence += 1 # be persistent
    passion = True # have passion

    if magic2 > magic:
    print("this doesn't work")
    magic = dedication + persistence
    return magic
    else:
    print("Success is near")
    magic = 0
    return magic
    # Succes is near
    please help me with this code i don't know how to fix it