• @funkless_eck@sh.itjust.works
    link
    fedilink
    3
    edit-2
    2 days ago

    _ (sic) as a variable name is often used when a function returns multiple outputs but you only want one

     def my_function:
          return 1, 2, 3
    
     _, two, _ = my_function()
    
    • @ryedaft@sh.itjust.works
      link
      fedilink
      English
      6
      edit-2
      11 hours ago

      Underscore alone is a special variable name and I’m pretty sure anything assigned to it goes straight to garbage collection. Whereas _myvariable is typically used to indicate a “private” class variable or method (Python doesn’t have private so it’s just a convention).