Skip to content

Commit

Permalink
Merge branch 'master' into is_valid_language_code
Browse files Browse the repository at this point in the history
  • Loading branch information
LBeaudoux authored Oct 22, 2024
2 parents e91201f + 49a807e commit f5095df
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,21 @@ Lang(name='Dari', pt1='', pt2b='', pt2t='', pt3='prs', pt5='')]

### In Data Structures

Lists of `Lang` instances are sortable by name.
```python
>>> [lg.name for lg in sorted([Lang("deu"), Lang("rus"), Lang("eng")])]
['English', 'German', 'Russian']
```
As `Lang` is hashable, `Lang` instances can be added to a set or used as dictionary keys.
```python
>>> {Lang("de"): "foo", Lang("fr"): "bar"}
{Lang(name='German', pt1='de', pt2b='ger', pt2t='deu', pt3='deu', pt5=''): 'foo', Lang(name='French', pt1='fr', pt2b='fre', pt2t='fra', pt3='fra', pt5=''): 'bar'}
```

Lists of `Lang` instances are sortable by name.
```python
>>> [lg.name for lg in sorted([Lang("deu"), Lang("rus"), Lang("eng")])]
['English', 'German', 'Russian']
```

### Iterator

`iter_langs` iterates through all possible `Lang` instances, ordered alphabetically by name.
`iter_langs()` iterates through all possible `Lang` instances, ordered alphabetically by name.

```python
>>> from iso639 import iter_langs
Expand Down

0 comments on commit f5095df

Please sign in to comment.