Python Forum
Why do we use __main__ when we can call a function directly?
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why do we use __main__ when we can call a function directly?
#4
Thanks to both for the quick response.

Does this mean that if I am not planning to import, then I can just directly call the functions and not put them under main. Apologies for my ignorance, but since I am not able to see the difference or understand which is better of the two, I am asking it again.
Reply


Messages In This Thread
RE: Why do we use __main__ when we can call a function directly? - by Dave7Swift - Jun-03-2018, 08:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  __name__ and __main__ in functions Mark17 3 871 Oct-12-2023, 01:55 AM
Last Post: deanhystad
  How do I call sys.argv list inside a function, from the CLI? billykid999 3 891 May-02-2023, 08:40 AM
Last Post: Gribouillis
  Import XML file directly into Excel spreadsheet demdej 0 917 Jan-24-2023, 02:48 PM
Last Post: demdej
  question about if __name__=="__main__" aaander 6 1,531 Nov-13-2022, 09:06 PM
Last Post: deanhystad
  if __name__=='__main__' albin2005 3 2,230 Sep-07-2021, 09:21 AM
Last Post: albin2005
  how to call an object in another function in Maya bstout 0 2,151 Apr-05-2021, 07:12 PM
Last Post: bstout
  In this function y initially has no value, but a call to foo() gives no error. Why? Pedroski55 8 3,627 Dec-19-2020, 07:30 AM
Last Post: ndc85430
  Struggling for the past hour to define function and call it back godlyredwall 2 2,302 Oct-29-2020, 02:45 PM
Last Post: deanhystad
  list call problem in generator function using iteration and recursive calls postta 1 2,010 Oct-24-2020, 09:33 PM
Last Post: bowlofred
  function call at defined system time? Holon 5 3,333 Oct-06-2020, 03:58 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020