tshirtman, French
@tshirtman@mas.to avatar

I sometimes see people write in

> isinstance(value, int) or isinstance(value, str)

although isinstance has been able to check for multiple types at once for as long as i remember, using.

> isinstance(value, (int, str))

so i refered someone to the official doc today https://docs.python.org/3/library/functions.html#isinstance

and realized it’s even better now, one can use union types

> isinstance(value, int | str)

Easy to miss that improvement if as me you’ve been using python for long enough you don’t look up docs.

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