Karim shoair commited on
Commit ·
ee0de9b
1
Parent(s): ff3cdb9
feat: add `length` property to `Selectors` to write less code
Browse files- scrapling/parser.py +5 -0
scrapling/parser.py
CHANGED
|
@@ -1377,6 +1377,11 @@ class Selectors(List[Selector]):
|
|
| 1377 |
"""Returns the last item of the current list or `None` if the list is empty"""
|
| 1378 |
return self[-1] if len(self) > 0 else None
|
| 1379 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1380 |
def __getstate__(self) -> Any:
|
| 1381 |
# lxml don't like it :)
|
| 1382 |
raise TypeError("Can't pickle Selectors object")
|
|
|
|
| 1377 |
"""Returns the last item of the current list or `None` if the list is empty"""
|
| 1378 |
return self[-1] if len(self) > 0 else None
|
| 1379 |
|
| 1380 |
+
@property
|
| 1381 |
+
def length(self):
|
| 1382 |
+
"""Returns the length of the current list"""
|
| 1383 |
+
return len(self)
|
| 1384 |
+
|
| 1385 |
def __getstate__(self) -> Any:
|
| 1386 |
# lxml don't like it :)
|
| 1387 |
raise TypeError("Can't pickle Selectors object")
|