treyhunner,
@treyhunner@mastodon.social avatar

@FunkyBob I'm always torn between using a walrus in this case or using a generator expression followed by a list comprehension. I do both, and sometimes one seems more readable than the other and sometimes the other seems more readable. 🤷

initial_results = (
term
for item in sequence
term := item.do_something()
)
result = [
term
for item in initial_results
if term != None
]

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