File: common_use_cases.rst

package info (click to toggle)
pyphen 0.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,456 kB
  • sloc: python: 248; makefile: 14; sh: 10
file content (26 lines) | stat: -rw-r--r-- 640 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Common Use Cases
================

pyphen has been created for WeasyPrint and many common use cases can thus be
found in `its repository`_.

.. _its repository: https://github.com/Kozea/WeasyPrint


.. code-block:: python

   >>> import pyphen
   >>> pyphen.language_fallback('nl_NL_variant1')
   'nl_NL'
   >>> 'nl_NL' in pyphen.LANGUAGES
   True
   >>> dic = pyphen.Pyphen(lang='nl_NL')
   >>> dic.inserted('lettergrepen')
   'let-ter-gre-pen'
   >>> dic.wrap('autobandventieldopje', 11)
   ('autoband-', 'ventieldopje')
   >>> for pair in dic.iterate('Amsterdam'):
   ...     print(pair)
   ...
   ('Amster', 'dam')
   ('Am', 'sterdam')