• thebestaquaman@lemmy.world
      link
      fedilink
      arrow-up
      11
      ·
      11 hours ago

      Oh, just wait till you hit that sweet sweet python “Everything can have an else block”

      if some_shit:
          try: 
              for stuff in thing:
                   if stuff is bad:
                        raise ShitHitTheFanError
                   # Massive block comment
                   do = the_thing()
                   if do is good:
                        break
              else:
                  do = the_other_thing()
                  if not a_thing:
                      help_me() # May raise NoHelpFoundError
          except ShitHitTheFanError:
               my_life = recover()
               if my_life is bad:
                   for fuck in my_life:
                        try:
                            fix(fuck)
                        except NoHelpFoundError:
                            break
                   else:
                        fuck_this_shit()
          else:
               wat_is_going_on()
      else:
          theres_another_one("?")
      
      • Big_Boss_77@fedinsfw.app
        link
        fedilink
        English
        arrow-up
        5
        ·
        edit-2
        8 hours ago

        I’m a network engineer lol python is all I know… and yup, the else is a curve ball from hell

        But this is absolutely fucking hilarious