Returns the first element of the sequence. >>> seq([1, 2, 3]).head() 1 Raises IndexError when the sequence is empty. >>> seq([]).head() Traceback (most recent call last): ... IndexError: list index out of range :return: fi
(self)
| 221 | return self |
| 222 | |
| 223 | def head(self): |
| 224 | """ |
| 225 | Returns the first element of the sequence. |
| 226 | |
| 227 | >>> seq([1, 2, 3]).head() |
| 228 | 1 |
| 229 | |
| 230 | Raises IndexError when the sequence is empty. |
| 231 | |
| 232 | >>> seq([]).head() |
| 233 | Traceback (most recent call last): |
| 234 | ... |
| 235 | IndexError: list index out of range |
| 236 | |
| 237 | :return: first element of sequence |
| 238 | """ |
| 239 | return _wrap(self.take(1)[0]) |
| 240 | |
| 241 | def first(self): |
| 242 | """ |