2👍
✅
first Article:
next(obj for obj in all_articles if isinstance(obj, Article))
last Article
next(obj for obj in all_articles[::-1] if isinstance(obj, Article))
first SharedArticle:
next(obj for obj in all_articles if isinstance(obj, SharedArticle))
last SharedArticle
next(obj for obj in all_articles[::-1] if isinstance(obj, SharedArticle))
👤sax
Source:stackexchange.com