From 715dfb4243e177bed0a147c56051a5119bae6081 Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Tue, 29 Jul 2025 06:19:45 +0300 Subject: [PATCH] feat: add `length` property to `Selectors` to write less code --- scrapling/parser.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scrapling/parser.py b/scrapling/parser.py index edc41f6..daddc9d 100644 --- a/scrapling/parser.py +++ b/scrapling/parser.py @@ -1377,6 +1377,11 @@ class Selectors(List[Selector]): """Returns the last item of the current list or `None` if the list is empty""" return self[-1] if len(self) > 0 else None + @property + def length(self): + """Returns the length of the current list""" + return len(self) + def __getstate__(self) -> Any: # lxml don't like it :) raise TypeError("Can't pickle Selectors object")