Python Forum
code style - one line subclause on same line
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
code style - one line subclause on same line
#1
i used to use this style
   if value is True: count += 1
but i have changed to this style
  if value in True:
        count += 1
but now i am reconsidering.  i think that in some cases the one line style can be easier to understand, especially if multiple related clauses are lined up vertically, such as
    if ch in ('t','T'): return True
    if ch in ('f','F'): return False
    else:               return None
so i would not be going back all the way but just part way, just doing it in cases that seem to me to add to readability.  even though this example is simple to understand, IMHO, it is quicker to read this way.

comments?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
code style - one line subclause on same line - by Skaperen - Nov-28-2017, 02:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  can a number preceed a line of code? Skaperen 4 427 May-09-2024, 02:50 AM
Last Post: Skaperen
Lightbulb traceback and multi-line statement Skaperen 0 866 Jan-31-2023, 12:23 AM
Last Post: Skaperen
Lightbulb Open-source ML-based line completion IDE plugin Aekalix 0 1,219 Jun-08-2022, 02:28 PM
Last Post: Aekalix
  a form of coded logic in a comand line Skaperen 10 3,019 Mar-02-2022, 08:43 PM
Last Post: Skaperen
  review of command line parsers Skaperen 2 2,141 Mar-11-2021, 07:39 PM
Last Post: Skaperen
  command line options Skaperen 5 2,761 Aug-14-2020, 08:48 AM
Last Post: DeaD_EyE
  opening python from the command line takes a long time to load? abdulkaderanwar 4 3,126 Jun-22-2020, 03:42 AM
Last Post: abdulkaderanwar
  f-string in command line arguments Skaperen 0 1,660 May-05-2020, 11:49 PM
Last Post: Skaperen
  my own command line option parser Skaperen 0 1,699 Mar-27-2020, 04:14 AM
Last Post: Skaperen
  abusing comprehensions for one line loops Skaperen 6 2,615 Dec-16-2019, 11:22 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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