File: types.rst

package info (click to toggle)
python-funcy 2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 536 kB
  • sloc: python: 2,989; makefile: 140; javascript: 96; sh: 6
file content (46 lines) | stat: -rw-r--r-- 1,184 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Type testing
============

.. function:: isa(*types)

    Returns function checking if its argument is of any of given ``types``.

    Split labels from ids::

        labels, ids = lsplit(isa(str), values)


.. function:: is_mapping(value)
              is_set(value)
              is_list(value)
              is_tuple(value)
              is_seq(value)
              is_iter(value)

    These functions check if value is ``Mapping``, ``Set``, ``list``, ``tuple``, ``Sequence`` or iterator respectively.


.. function:: is_seqcoll(value)

    Checks if ``value`` is a list or a tuple, which are both sequences and collections.


.. function:: is_seqcont(value)

    Checks if ``value`` is a list, a tuple or an iterator, which are sequential containers. It can be used to distinguish between value and multiple values in dual-interface functions::

        def add_to_selection(view, region):
            if is_seqcont(region):
                # A sequence of regions
                view.sel().add_all(region)
            else:
                view.sel().add(region)


.. function:: iterable(value)

    Tests if ``value`` is iterable.


.. raw:: html
    :file: descriptions.html