wrap¶
- class pythonic_fp.gadgets.wrap.Wrap¶
Bases:
GenericWrap
Immutablely wrap exactly one item.
Tip
Wrapobjects are matchable.- __init__(item: T) None¶
init
Initialize
Wrapwith 1 required item.- param item:
Item to be wrapped.
- __bool__() bool¶
bool
Truthiness same as wrapped object.
- __len__() int¶
len
Wrapped items always contain just one item.
- returns:
1
- __iter__() Iterator¶
iter
- yields:
A reference to the wrapped item.
- __eq__(other: object) bool¶
equality comparison
Compare
Wrapto another object.- param other:
Object to be compared.
- returns:
Trueifotheris of type Wrap and wraps an item which compares as equal to the wrapped item, otherwiseFalse.
- __repr__() str¶
repr string
Construct string ‘Wrap(item_str)’ where
item_str = repr(item)for the contained item.- returns:
A string to reproduce of the wrapped item.
- __str__() str¶
user string
Construct string ‘Wrap(item_str)’ where
item_str = str(item)for the contained item.- returns:
A string meaningful to an end user.
- class pythonic_fp.gadgets.wrap.HWrap¶
Bases:
Hashable,GenericHWrap
Immutablely wrap exactly one hashable item.
Tip
HWrapobjects are hashable and matchable.- __init__(item: T) None¶
init
Initialize
HWrapwith 1 required item.- param item:
Item to be wrapped.
- __hash__() int¶
Return hash(self).
- __bool__() bool¶
bool
Truthiness same as wrapped object.
- __len__() int¶
len
HWrapped items always contain just one item.
- returns:
1
- __iter__() Iterator¶
iter
- yields:
A reference to the wrapped item.
- __eq__(other: object) bool¶
equality comparison
Compare
HWrapto another object.- param other:
Object to be compared.
- returns:
Trueifotheris of type HWrap and wraps an item which compares as equal to the wrapped item, otherwiseFalse.
- __repr__() str¶
repr string
Construct string ‘HWrap(item_str)’ where
item_str = repr(item)for the contained item.- returns:
A string to reproduce of the wrapped object.
- __str__() str¶
user string
Construct string ‘HWrap(item_str)’ where
item_str = str(item)for the contained item.- returns:
A string meaningful to an end user.