treyhunner,
@treyhunner@mastodon.social avatar

With the "else", this code looks to me a bit like a balance scale, with an "if" and an "else" on either side.

Read more 👉 https://trey.io/FlSco3

_KevinTrainor,
@_KevinTrainor@mastodon.online avatar

@treyhunner I am old enough to remember when structured programmers did not create functions with more than one exit. So, I prefer a single return at the bottom of the function. I know that is old-fashioned. But, I never need to wonder about how I exited the function.

treyhunner,
@treyhunner@mastodon.social avatar

@_KevinTrainor folks keep noting the one exit point coding style in regards to this video and I'm surprised at how common this style is in Python.

I've never been a convert to this style of coding and I suspect that it no longer makes sense in Python, but I need to do some research to make my case.

if I put together some challenges that will attempt to poke holes in this style, would you be interested in trying to rebut those challenges?

I'd like to understand the mindset of folks using this.

_KevinTrainor,
@_KevinTrainor@mastodon.online avatar

@treyhunner I would definitely be interested in reading your challenges and responding. If I were to try to summarize my point of view on this subject, I would say that every exit from a function beyond the first exit has a cost to the code reader. So, my goal is to minimize that cost.

treyhunner,
@treyhunner@mastodon.social avatar

@_KevinTrainor 👍 I'll give this some more thought after PyCon. Thanks!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • python
  • kavyap
  • ngwrru68w68
  • GTA5RPClips
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • thenastyranch
  • Youngstown
  • Durango
  • slotface
  • everett
  • vwfavf
  • rosin
  • Leos
  • normalnudes
  • khanakhh
  • cisconetworking
  • cubers
  • InstantRegret
  • ethstaker
  • osvaldo12
  • modclub
  • anitta
  • provamag3
  • tacticalgear
  • tester
  • megavids
  • JUstTest
  • All magazines