multimeric,
@multimeric@genomic.social avatar

Shiny for Python has you pass in functions to App() rather than grouping them into a class or using decorators. It seems a bit unpythonic to me. You even nest function definitions for some reason?

meejah,
@meejah@mastodon.social avatar

@multimeric That looks reasonable to me -- what's the issue?

multimeric,
@multimeric@genomic.social avatar

@meejah It just seems like they copy-pasted the R API into Python. It works in R because it's a very functional language, but idiomatic/user-friendly Python uses classes in my opinion. Especially because a Shiny app is so cleanly modelled as a class that implements an interface.

I'd rather see it look something like this

meejah,
@meejah@mastodon.social avatar

@multimeric This probably comes down to one of us preferring composition and one preferring inheritance?

I don't think there's anything intrinsically "more Pythonic" about forcing subclassing like that...

multimeric,
@multimeric@genomic.social avatar

@meejah Touche, I think that's an accurate observation. But really it's not that I prefer inheritance, I just think that Python has better tools to create rich APIs using it, via metaclasses and class hooks.

meejah,
@meejah@mastodon.social avatar

@multimeric That's fine, we're allowed to prefer our own style -- but I don't think there's anything intrinsically "Pythonic" about that approach (and there's plenty of Python that specifically doesn't take such an approach, preferring composition).

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