Python Forum
Question about an infinite loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about an infinite loop
#3
(Mar-04-2018, 04:45 AM)Robo_Pi Wrote: I can't imagine that it hurts anything to leave that redundant return in the code?
A main() function is not special in a python program, it is an ordinary function. A program doesn't need a main function. When there is no return statement in a function, it returns None (if it ever returns). It means that a return statement is never necessary. In your case, the return statement is useless because it is never executed.

The return value of the main function is not the same thing as the program's exit status (because main() is not special) unless you call sys.exit(main()) as wavic does. The program should exit with value 0 to indicate success.
Reply


Messages In This Thread
Question about an infinite loop - by Robo_Pi - Mar-04-2018, 04:45 AM
RE: Question about an infinite loop - by wavic - Mar-04-2018, 05:19 AM
RE: Question about an infinite loop - by Gribouillis - Mar-04-2018, 06:24 AM
RE: Question about an infinite loop - by Robo_Pi - Mar-04-2018, 05:44 PM
RE: Question about an infinite loop - by wavic - Mar-04-2018, 06:45 PM
RE: Question about an infinite loop - by Robo_Pi - Mar-04-2018, 08:42 PM
RE: Question about an infinite loop - by wavic - Mar-05-2018, 05:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Shocked Why this code does not go into an infinite loop? 2367409125 2 906 Dec-02-2022, 08:22 PM
Last Post: deanhystad
  Need help with infinite loop & making hotkeys/shortcuts Graxum 1 1,219 Aug-22-2022, 02:57 AM
Last Post: deanhystad
  A question about 'Event loop is closed' fc5igm 2 2,280 Oct-05-2021, 02:00 AM
Last Post: fc5igm
Exclamation question about input, while loop, then print jamie_01 5 2,742 Sep-30-2021, 12:46 PM
Last Post: Underscore
  Infinite loop problem Zirconyl 5 3,051 Nov-16-2020, 09:06 AM
Last Post: DeaD_EyE
  for loop question KEYS 1 1,757 Oct-27-2020, 11:42 PM
Last Post: jefsummers
  Netmiko Loop question sc00ter 2 3,367 Oct-24-2020, 10:54 PM
Last Post: sc00ter
  using 'while loop' output going into infinite loop... amitkb 2 2,008 Oct-05-2020, 09:18 PM
Last Post: micseydel
  while loop question KEYS 2 2,062 Sep-26-2020, 11:02 PM
Last Post: KEYS
  New to programming, loop question tomyan 1 1,682 Sep-25-2020, 04:32 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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