Python 3.8's Assignment Expressions, aka the Walrus operator, feel like an excellent pattern for checking optional environment variables that are only needed to initialize a library like Sentry.
1 2 3 4 5 | if SENTRY_DSN := env("DJANGO_SENTRY_DSN", default=None):
sentry_sdk.init(
dsn=SENTRY_DSN,
integrations=[DjangoIntegration(), RedisIntegration()],
)
|
More like this
- Auto upload_to path generator by junaidmgithub 5 hours, 21 minutes ago
- LazyPrimaryKeyRelatedField by LLyaudet 1 week ago
- CacheInDictManager by LLyaudet 1 week ago
- MYSQL Full Text Expression by Bidaya0 1 week, 1 day ago
- Custom model manager chaining (Python 3 re-write) by Spotted1270 2 weeks, 1 day ago
Comments
Please login first before commenting.