Browse Source

Iterator section rearranged

pull/21/head
Jure Šorn 5 years ago
parent
commit
580179e353
1 changed files with 11 additions and 7 deletions
  1. 18
      README.md

18
README.md

@ -168,13 +168,6 @@ Iterator
<iter> = iter(<function>, to_exclusive)
```
#### Skips first element:
```python
next(<iter>, None) # default of `None` avoids exception for empty <iter>
for element in <iter>:
...
```
#### Reads input until it reaches an empty line:
```python
for line in iter(input, ''):
@ -188,6 +181,17 @@ for line in iter(partial(input, 'Please enter value: '), ''):
...
```
### Next
**Returns next item. If there are no more items it raises exception or returns default if specified.**
<el> = next(<iter> [, default])
#### Skips first item:
```python
next(<iter>, None)
for element in <iter>:
...
```
Generator
---------

Loading…
Cancel
Save