Python Forum
a coding style question
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a coding style question
#4
I prefer the first. It makes it clear that the value is relevant outside of the if-block, whereas if it exists entirely indented, it appears at a glance as if it's not relevant outside that block.

Or the ternary version if it's simple. But if it isn't simple, it should probably be pulled out into it's own function anyway (something like lookup_location_name).
Reply


Messages In This Thread
a coding style question - by Skaperen - Sep-06-2019, 03:15 AM
RE: a coding style question - by wavic - Sep-06-2019, 05:17 AM
RE: a coding style question - by ichabod801 - Sep-06-2019, 12:02 PM
RE: a coding style question - by nilamo - Sep-10-2019, 04:09 PM

Forum Jump:

User Panel Messages

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