Python Forum
Multiple "return" statements or "result" variable?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple "return" statements or "result" variable?
#8
If true pythonista is in doubt he/she will turn to holy book of The Python Language Reference for truth, guidance and salvation. As per documentation, every devoted follower keeps it under pillow Smile .

In this case I was not able to find truth. However, guidance is quite clear: every code snippet that I have encountered so far is using multiple returns. Like in Built-in functions all(), any() or Built-in Types hashing float etc.

The smart people who wrote these snippets were well aware that millions on eager young pythonistas will consider these examples as best practices for Python code.

Conclusion is simple: using multiple returns is pythonic

One can be tempted to derive from that: using multiple results and one return is non-pythonic. I am not commited to that yet. In order to claim that I need to read all snippets provided and only after that make conclusion.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: Multiple "return" statements or "result" variable? - by perfringo - Jul-25-2018, 07:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  This result object does not return rows. It has been closed automatically dawid294 6 1,493 Mar-30-2024, 03:08 AM
Last Post: NolaCuriel
  Multiple variable inputs when only one is called for ChrisDall 2 556 Oct-20-2023, 07:43 PM
Last Post: deanhystad
  Multiple Loop Statements in a Variable Dexty 1 1,264 May-23-2022, 08:53 AM
Last Post: bowlofred
  how do I return Max Test result + corresponding student name from an excel dataset? sean1 3 1,344 Jan-16-2022, 09:07 PM
Last Post: snippsat
  Function - Return multiple values tester_V 10 4,708 Jun-02-2021, 05:34 AM
Last Post: tester_V
  Multiple Or Statements JoeDainton123 8 2,763 Sep-15-2020, 08:14 PM
Last Post: buran
  Function will not return variable that I think is defined Oldman45 6 3,667 Aug-18-2020, 08:50 PM
Last Post: deanhystad
  Decorators and return statements JonEdward 2 1,981 Jul-24-2020, 05:02 PM
Last Post: JonEdward
  Help creating a variable as a result Realen 2 1,843 Jun-18-2020, 04:46 AM
Last Post: Realen
  How to pass multiple values from one sample to nc variable? Baloch 0 1,905 Jun-01-2020, 09:27 PM
Last Post: Baloch

Forum Jump:

User Panel Messages

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