File: trait_types.rst

package info (click to toggle)
traitlets 5.14.3%2Breally5.14.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,180 kB
  • sloc: python: 10,581; makefile: 176
file content (117 lines) | stat: -rw-r--r-- 2,153 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Trait Types
===========

.. module:: traitlets

.. class:: TraitType

   The base class for all trait types.

   .. automethod:: __init__

   .. automethod:: from_string

Numbers
-------

.. autoclass:: Integer

   An integer trait. On Python 2, this automatically uses the ``int`` or
   ``long`` types as necessary.

.. class:: Int
.. class:: Long

   On Python 2, these are traitlets for values where the ``int`` and ``long``
   types are not interchangeable. On Python 3, they are both aliases for
   :class:`Integer`.

   In almost all situations, you should use :class:`Integer` instead of these.

.. autoclass:: Float

.. autoclass:: Complex

.. class:: CInt
           CLong
           CFloat
           CComplex

   Casting variants of the above. When a value is assigned to the attribute,
   these will attempt to convert it by calling e.g. ``value = int(value)``.

Strings
-------

.. autoclass:: Unicode

.. autoclass:: Bytes

.. class:: CUnicode
           CBytes

   Casting variants. When a value is assigned to the attribute, these will
   attempt to convert it to their type. They will not automatically encode/decode
   between unicode and bytes, however.

.. autoclass:: ObjectName

.. autoclass:: DottedObjectName

Containers
----------

.. autoclass:: List
   :members: __init__, from_string_list, item_from_string

.. autoclass:: Set
   :members: __init__

.. autoclass:: Tuple
   :members: __init__

.. autoclass:: Dict
   :members: __init__, from_string_list, item_from_string

Classes and instances
---------------------

.. autoclass:: Instance
   :members: __init__

.. autoclass:: Type
   :members: __init__

.. autoclass:: This

.. autoclass:: ForwardDeclaredInstance

.. autoclass:: ForwardDeclaredType


Miscellaneous
-------------

.. autoclass:: Bool

.. class:: CBool

   Casting variant. When a value is assigned to the attribute, this will
   attempt to convert it by calling ``value = bool(value)``.

.. autoclass:: Enum

.. autoclass:: CaselessStrEnum

.. autoclass:: UseEnum

.. autoclass:: TCPAddress

.. autoclass:: CRegExp

.. autoclass:: Union
   :members: __init__

.. autoclass:: Callable

.. autoclass:: Any