nustack
ReferenceNucontext

attrs.refs

`AttrRef` and its typed variants.

Module nu.context.attrs.refs.

AttrRef and its typed variants.

An AttrRef names a slot in ctx.attrs by its resolved address (any child that yields a value). Reads self-yield the value at that key (EMPTY when unbound); writes and erases go through the Ref so a Command never touches ctx.attrs directly - the write mechanism lives with the fabric.

NameSortCallMeaning
AnyAttrRefrefAnyAttrRef()An AttrRef with the dynamic any interface.
AttrRefrefAttrRef(address)A Ref into the ctx.attrs store, keyed by its resolved address.
BoolAttrRefrefBoolAttrRef()An AttrRef with the full boolean interface.
BytesAttrRefrefBytesAttrRef()An AttrRef with the full bytes interface.
DictAttrRefrefDictAttrRef()An AttrRef with the full dict interface.
FloatAttrRefrefFloatAttrRef()An AttrRef with the full float interface.
FrozenSetAttrRefrefFrozenSetAttrRef()An AttrRef with the full frozenset interface.
IntAttrRefrefIntAttrRef()An AttrRef with the full integer interface.
ListAttrRefrefListAttrRef()An AttrRef with the full list interface.
NoneAttrRefrefNoneAttrRef(source=None)An AttrRef with the none interface.
SetAttrRefrefSetAttrRef()An AttrRef with the full set interface.
StrAttrRefrefStrAttrRef()An AttrRef with the full string interface.
TupleAttrRefrefTupleAttrRef()An AttrRef with the full tuple interface.

AnyAttrRef

An AttrRef with the dynamic any interface.

AnyAttrRef()

Path nu.context.AnyAttrRef. Kind Ref, sort ref, cardinality scalar.

Inherited methods

From nu.context.attrs.refs.AttrRef:

CallBuildsMeaning
.exists()AttrExistsA Query yielding whether this Ref's address is bound in ctx.attrs.

From nu.forms.primitives.any_.Any:

CallBuildsMeaning
a + bAnySum of self and other.
a - bAnySelf minus other.
a * bAnyProduct of self and other.
a @ bAnyMatrix multiplication: self @ other.
a / bAnySelf divided by other.
a // bAnySelf floor-divided by other.
a % bAnySelf modulo other.
a ** bAnySelf raised to the other power.
-aAnyNegation of self.
+aAnySelf unchanged.
abs(a)AnyAbsolute value of self.
a > bBoolSelf strictly greater than other.
a < bBoolSelf strictly less than other.
a >= bBoolSelf greater than or equal to other.
a <= bBoolSelf less than or equal to other.
a == bBoolSelf equal to other by value.
a != bBoolSelf not equal to other by value.
.is_(other)BoolIdentity comparison: self is other.
.and_(other)BoolLogical AND of self and other.
.or_(other)BoolLogical OR of self and other.
.not_()BoolLogical NOT of self.
.bool_()BoolCast self to Bool.
.bitand(other)AnyBitwise AND: self & other.
.bitor(other)AnyBitwise OR: self | other.
.bitnot()AnyBitwise NOT: ~self.
~aAnyBitwise NOT: ~self.
a ^ bAnyBitwise XOR: self ^ other.
a << bAnyLeft shift: self shifted left by other bits.
a >> bAnyRight shift: self shifted right by other bits.
a[key]AnySubscript access: self[key].
a[key] = valueobjectSubscript write: self[key] = value.
.len_()IntLength of self, as len(self).
.contains(item)BoolMembership test: item in self.
.iter_()IteratorIterator over self, as iter(self).
.has_attr(name)BoolAttribute presence: hasattr(self, name).

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

Undocumented: example.

AttrRef

A Ref into the ctx.attrs store, keyed by its resolved address.

AttrRef(address)

Path nu.context.AttrRef. Kind Ref, sort ref, cardinality scalar.

The sole child is the address, evaluated through the runtime like any other child, so a key can be fixed at write time or computed at run time. Reading is the dual role: the Ref self-yields whatever sits at that key. Writing and erasing never happen at the call site - a Command hands the Ref its own node id, the Ref resolves its address and touches the store, so the write mechanism stays with the fabric.

Notes

  • An unbound slot and a slot holding EMPTY read the same, so reach for .exists() when the difference matters.
  • ctx.attrs is the short-lived axis of the Context fabric: loop variables, counters, accumulators, markers. Anything longer-lived is a typed binding, read through FabricRef.
  • Map and Filter bind their per-item loop variable into this same store, which is why a body reads the item with an AttrRef.
  • The typed variants mix a Form in for its operator surface only. Nothing checks that the value at the key really has that type; an IntAttrRef over an unbound slot yields EMPTY, and arithmetic on it collapses to INVALID like any other sentinel operand.

Examples

nu.run(nu.AttrRef("missing"))[0]
<EMPTY>
nu.run(nu.SetCmd(nu.AttrRef("total"), 10))[1].attrs
Attributes(total=10)
key = nu.SetCmd(nu.AttrRef("k"), "total")
nu.run(nu.Sequential(key, nu.SetCmd(nu.AttrRef(nu.AttrRef("k")), 5)))[1].attrs
Attributes(k='total', total=5)

Methods

.exists()

A Query yielding whether this Ref's address is bound in ctx.attrs.

Builds AttrExists.

Notes

  • The plain read cannot answer this: an unbound slot yields EMPTY and so does a slot bound to EMPTY.
  • Only the address is resolved; the slot's value is never read.

Undocumented: example.

BoolAttrRef

An AttrRef with the full boolean interface.

BoolAttrRef()

Path nu.context.BoolAttrRef. Kind Ref, sort ref, cardinality scalar.

Inherited methods

From nu.context.attrs.refs.AttrRef:

CallBuildsMeaning
.exists()AttrExistsA Query yielding whether this Ref's address is bound in ctx.attrs.

From nu.forms.primitives.bool_.Bool:

CallBuildsMeaning
.and_(other)BoolLogical AND of self and other.
.or_(other)BoolLogical OR of self and other.
.not_()BoolLogical NOT of self.
.bool_()BoolCast self to Bool.
a > bBoolSelf strictly greater than other.
a < bBoolSelf strictly less than other.
a >= bBoolSelf greater than or equal to other.
a <= bBoolSelf less than or equal to other.
a == bBoolSelf equal to other by value.
a != bBoolSelf not equal to other by value.
.is_(other)BoolIdentity comparison: self is other.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

Undocumented: example.

BytesAttrRef

An AttrRef with the full bytes interface.

BytesAttrRef()

Path nu.context.BytesAttrRef. Kind Ref, sort ref, cardinality scalar.

Inherited methods

From nu.context.attrs.refs.AttrRef:

CallBuildsMeaning
.exists()AttrExistsA Query yielding whether this Ref's address is bound in ctx.attrs.

From nu.forms.primitives.bytes_.Bytes:

CallBuildsMeaning
a + bBytesConcatenation of self and other.
a[key]Bytes | IntByte at an index, or a sub-range by slice.
a > bBoolSelf strictly greater than other.
a < bBoolSelf strictly less than other.
a >= bBoolSelf greater than or equal to other.
a <= bBoolSelf less than or equal to other.
a == bBoolSelf equal to other by value.
a != bBoolSelf not equal to other by value.
.is_(other)BoolIdentity comparison: self is other.
.and_(other)BoolLogical AND of self and other.
.or_(other)BoolLogical OR of self and other.
.not_()BoolLogical NOT of self.
.bool_()BoolCast self to Bool.
.decode(encoding='utf-8')StrDecode self to a string using the given encoding.
.hex_()StrHex string of self, two digits per byte.
.upper()BytesSelf with ASCII letters uppercased.
.lower()BytesSelf with ASCII letters lowercased.
.strip(chars=None)BytesSelf with leading and trailing bytes removed.
.lstrip(chars=None)BytesSelf with leading bytes removed.
.rstrip(chars=None)BytesSelf with trailing bytes removed.
.split_bytes(sep=None, maxsplit=-1)ListSelf split into a List of Bytes on sep.
.find_bytes(sub, start=0, end=None)IntLowest index of sub in self, or -1 if absent.
.count_bytes(sub)IntNumber of non-overlapping occurrences of sub in self.
.startswith(prefix)BoolSelf starts with prefix.
.endswith(suffix)BoolSelf ends with suffix.
.replace(old, new, count=-1)BytesSelf with occurrences of old replaced by new.
.removeprefix(prefix)BytesSelf with prefix removed if present.
.removesuffix(suffix)BytesSelf with suffix removed if present.
.translate(table, delete=b'')BytesSelf translated through a 256-byte table, with bytes in delete dropped first.
.title()BytesSelf titlecased: each word's first cased byte upper, the rest lower.
.capitalize()BytesSelf with the first byte uppercased and the rest lowercased.
.swapcase()BytesSelf with uppercase and lowercase bytes swapped.
.rsplit_bytes(sep=None, maxsplit=-1)ListSelf split into a List of Bytes on sep, counting maxsplit from the right.
.splitlines(keepends=False)ListSelf split into a List of Bytes at line boundaries.
.partition(sep)TupleSelf split around the first occurrence of sep.
.rpartition(sep)TupleSelf split around the last occurrence of sep.
.rfind_bytes(sub, start=0, end=None)IntHighest index of sub in self, or -1 if absent.
.index_bytes(sub, start=0, end=None)IntLowest index of sub in self.
.rindex_bytes(sub, start=0, end=None)IntHighest index of sub in self.
.isascii()BoolSelf has only ASCII bytes.
.isdigit()BoolSelf has only ASCII digit bytes, and at least one.
.isalpha()BoolSelf has only ASCII letter bytes, and at least one.
.isalnum()BoolSelf has only ASCII alphanumeric bytes, and at least one.
.isspace()BoolSelf has only ASCII whitespace bytes, and at least one.
.istitle()BoolSelf is titlecased, with at least one cased byte.
.isupper()BoolSelf has all cased bytes uppercase, and at least one cased byte.
.islower()BoolSelf has all cased bytes lowercase, and at least one cased byte.
.center(width, fillbyte=b' ')BytesSelf centered in a field of width, padded with fillbyte.
.ljust(width, fillbyte=b' ')BytesSelf left-justified in a field of width, padded with fillbyte.
.rjust(width, fillbyte=b' ')BytesSelf right-justified in a field of width, padded with fillbyte.
.zfill(width)BytesSelf padded with leading zero bytes to width.
.expandtabs(tabsize=8)BytesSelf with tab bytes expanded to spaces.
.join(iterable)BytesSelf used as separator between the elements of iterable.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

Undocumented: example.

DictAttrRef

An AttrRef with the full dict interface.

DictAttrRef()

Path nu.context.DictAttrRef. Kind Ref, sort ref, cardinality scalar.

Inherited methods

From nu.context.attrs.refs.AttrRef:

CallBuildsMeaning
.exists()AttrExistsA Query yielding whether this Ref's address is bound in ctx.attrs.

From nu.forms.collections.dict_.Dict:

CallBuildsMeaning
DictAttrRef.create()Dict[K, V]Fresh empty dict.
DictAttrRef.of(fields)Dict[str, V]Dict built from named field expressions.
a[key]Value at key.
.keys()DictKeys[K]Self's keys as a live view.
.values()DictValues[V]Self's values as a live view.
.items()DictItems[K, V]Self's key-value pairs as a live view.
a > bBoolSelf strictly greater than other.
a < bBoolSelf strictly less than other.
a >= bBoolSelf greater than or equal to other.
a <= bBoolSelf less than or equal to other.
a == bBoolSelf equal to other by value.
a != bBoolSelf not equal to other by value.
.is_(other)BoolIdentity comparison: self is other.

From nu.forms.collections.abc.mapping.MutableMappingForm:

CallBuildsMeaning
.set_item(key, value)AnySet the value at key, inserting the key if it's missing: mapping[key] = value.
.del_item(key)AnyDelete the entry at key: del mapping[key].
.update(other)AnyWrite other's entries into self, in place: mapping.update(other).
.pop(key, default=None)ValueResultTRemove key and yield its value, or default if key is missing.
.popitem()ValueResultTRemove and yield an arbitrary (key, value) pair: mapping.popitem().
.setdefault(key, default=None)ValueResultTValue at key, inserting default there first if key is missing.
.merge_update(other)CollectionResultTMerge other into self in place, and yield self: mapping |= other.
.clear()AnyRemove all entries: mapping.clear().

From nu.forms.collections.abc.mapping.MappingForm:

CallBuildsMeaning
.get_item(key, default=None)ValueResultTValue at key, falling back to default: mapping.get_item(key, default).
.copy()CollectionResultTShallow copy of self: mapping.copy().
.reversed_keys()CollectionResultTKeys in reverse insertion order: reversed(mapping).
.reversed_values()CollectionResultTValues in reverse insertion order: reversed(mapping.values()).
.reversed_items()CollectionResultT(key, value) pairs in reverse insertion order: reversed(mapping.items()).
.merge(other)CollectionResultTSelf and other merged into a new mapping: mapping | other.

From nu.forms.collections.abc.collection.CollectionForm:

CallBuildsMeaning
.extract()objectMaterialise the full subtree rooted at self.

From nu.forms.collections.abc.sized.SizedForm:

CallBuildsMeaning
.len()IntLength of self.

From nu.forms.collections.abc.iterable.IterableForm:

CallBuildsMeaning
iter(a)Iterator[ElementT]Open self into a lazy iterator stream (Python's iter).

From nu.forms.collections.abc.container.ContainerForm:

CallBuildsMeaning
.contains(item)BoolWhether item is a member of self.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

Undocumented: example.

FloatAttrRef

An AttrRef with the full float interface.

FloatAttrRef()

Path nu.context.FloatAttrRef. Kind Ref, sort ref, cardinality scalar.

Inherited methods

From nu.context.attrs.refs.AttrRef:

CallBuildsMeaning
.exists()AttrExistsA Query yielding whether this Ref's address is bound in ctx.attrs.

From nu.forms.primitives.float_.Float:

CallBuildsMeaning
a + bFloatSum of self and other.
a - bFloatSelf minus other.
a * bFloatProduct of self and other.
a / bFloatSelf divided by other.
a // bFloatSelf floor-divided by other.
a % bFloatSelf modulo other.
a ** bFloatSelf raised to the other power.
-aFloatNegation of self.
+aFloatSelf unchanged.
abs(a)FloatAbsolute value of self.
a > bBoolSelf strictly greater than other.
a < bBoolSelf strictly less than other.
a >= bBoolSelf greater than or equal to other.
a <= bBoolSelf less than or equal to other.
a == bBoolSelf equal to other by value.
a != bBoolSelf not equal to other by value.
.is_(other)BoolIdentity comparison: self is other.
.and_(other)BoolLogical AND of self and other.
.or_(other)BoolLogical OR of self and other.
.not_()BoolLogical NOT of self.
.bool_()BoolCast self to Bool.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

Undocumented: example.

FrozenSetAttrRef

An AttrRef with the full frozenset interface.

FrozenSetAttrRef()

Path nu.context.FrozenSetAttrRef. Kind Ref, sort ref, cardinality scalar.

Inherited methods

From nu.context.attrs.refs.AttrRef:

CallBuildsMeaning
.exists()AttrExistsA Query yielding whether this Ref's address is bound in ctx.attrs.

From nu.forms.collections.set_.FrozenSet:

CallBuildsMeaning
FrozenSetAttrRef.create()FrozenSet[T]Build an empty frozenset.
FrozenSetAttrRef.of(*items)FrozenSetBuild a frozenset from positional item expressions.
a > bBoolSelf is a proper superset of other.
a < bBoolSelf is a proper subset of other.
a >= bBoolSelf is a superset of other, or equal.
a <= bBoolSelf is a subset of other, or equal.
a == bBoolSelf equal to other by value.
a != bBoolSelf not equal to other by value.
.is_(other)BoolIdentity comparison: self is other.

From nu.forms.collections.abc.set_.SetLikeForm:

CallBuildsMeaning
.union(other)CollectionResultTUnion of self and other.
.intersection(other)CollectionResultTIntersection of self and other.
.difference(other)CollectionResultTElements of self that are not in other.
.symmetric_difference(other)CollectionResultTElements in exactly one of self and other, not both.
.issubset(other)BoolWhether every element of self is in other.
.issuperset(other)BoolWhether every element of other is in self.
.isdisjoint(other)BoolWhether self and other share no elements.
.copy()CollectionResultTShallow copy of self.
a | bCollectionResultTUnion: self | other.
a & bCollectionResultTIntersection: self & other.
a - bCollectionResultTDifference: self - other.
a ^ bCollectionResultTSymmetric difference: self ^ other.

From nu.forms.collections.abc.collection.CollectionForm:

CallBuildsMeaning
.extract()objectMaterialise the full subtree rooted at self.

From nu.forms.collections.abc.sized.SizedForm:

CallBuildsMeaning
.len()IntLength of self.

From nu.forms.collections.abc.iterable.IterableForm:

CallBuildsMeaning
iter(a)Iterator[ElementT]Open self into a lazy iterator stream (Python's iter).

From nu.forms.collections.abc.container.ContainerForm:

CallBuildsMeaning
.contains(item)BoolWhether item is a member of self.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

Undocumented: example.

IntAttrRef

An AttrRef with the full integer interface.

IntAttrRef()

Path nu.context.IntAttrRef. Kind Ref, sort ref, cardinality scalar.

Inherited methods

From nu.context.attrs.refs.AttrRef:

CallBuildsMeaning
.exists()AttrExistsA Query yielding whether this Ref's address is bound in ctx.attrs.

From nu.forms.primitives.int_.Int:

CallBuildsMeaning
a + bInt | FloatSum of self and other.
a - bInt | FloatSelf minus other.
a * bInt | FloatProduct of self and other.
a / bFloatSelf divided by other.
a // bInt | FloatSelf floor-divided by other.
a % bInt | FloatSelf modulo other.
a ** bInt | FloatSelf raised to the other power.
-aIntNegation of self.
+aIntSelf unchanged.
abs(a)IntAbsolute value of self.
a > bBoolSelf strictly greater than other.
a < bBoolSelf strictly less than other.
a >= bBoolSelf greater than or equal to other.
a <= bBoolSelf less than or equal to other.
a == bBoolSelf equal to other by value.
a != bBoolSelf not equal to other by value.
.is_(other)BoolIdentity comparison: self is other.
.and_(other)BoolLogical AND of self and other.
.or_(other)BoolLogical OR of self and other.
.not_()BoolLogical NOT of self.
.bool_()BoolCast self to Bool.
.bitand(other)IntBitwise AND: self & other.
.bitor(other)IntBitwise OR: self | other.
a ^ bIntBitwise XOR: self ^ other.
.bitnot()IntBitwise NOT: ~self.
a << bIntLeft shift: self shifted left by other bits.
a >> bIntRight shift: self shifted right by other bits.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

Undocumented: example.

ListAttrRef

An AttrRef with the full list interface.

ListAttrRef()

Path nu.context.ListAttrRef. Kind Ref, sort ref, cardinality scalar.

Inherited methods

From nu.context.attrs.refs.AttrRef:

CallBuildsMeaning
.exists()AttrExistsA Query yielding whether this Ref's address is bound in ctx.attrs.

From nu.forms.collections.list_.List:

CallBuildsMeaning
ListAttrRef.create()List[T]Yield a fresh empty list.
ListAttrRef.of(items)ListYield a list from positional item expressions.
a[key]Element at an int index, or subsequence for a slice.
a + bList[T]Concatenation of self and other.
a * bList[T]Self repeated n times.
a[key] = valueAnySubscript write: self[index] = value.
a > bBoolSelf strictly greater than other, element-by-element.
a < bBoolSelf strictly less than other, element-by-element.
a >= bBoolSelf greater than or equal to other, element-by-element.
a <= bBoolSelf less than or equal to other, element-by-element.
a == bBoolSelf equal to other by value.
a != bBoolSelf not equal to other by value.
.is_(other)BoolIdentity comparison: self is other.

From nu.forms.collections.abc.sequence.MutableSequenceForm:

CallBuildsMeaning
.append(value)AnyAppend value to the end of self.
.extend(other)AnyExtend self with the elements of other, in order.
.insert(index, value)AnyInsert value at index, shifting later elements right.
.pop(index=-1)ElementResultTRemove and return the element at index.
.del_at(index)AnyRemove the element at index.
.remove(value)AnyRemove the first occurrence of value.
.reverse()AnyReverse self in place.
.sort()AnySort self in place, ascending, using the elements' natural order.
.copy()CollectionResultTShallow copy of self: a new sequence with the same elements.
.clear()AnyRemove every element from self.

From nu.forms.collections.abc.sequence.SequenceForm:

CallBuildsMeaning
.first_elem()ElementResultTFirst element of self.
.last_elem()ElementResultTLast element of self.
.index(value)IntLowest index in self where value is found, searching from the left.
.count(value)IntCount of occurrences of value in self.
.reversed()CollectionResultTSelf walked back to front, as a stream.

From nu.forms.collections.abc.collection.CollectionForm:

CallBuildsMeaning
.extract()objectMaterialise the full subtree rooted at self.

From nu.forms.collections.abc.sized.SizedForm:

CallBuildsMeaning
.len()IntLength of self.

From nu.forms.collections.abc.iterable.IterableForm:

CallBuildsMeaning
iter(a)Iterator[ElementT]Open self into a lazy iterator stream (Python's iter).

From nu.forms.collections.abc.container.ContainerForm:

CallBuildsMeaning
.contains(item)BoolWhether item is a member of self.

From nu.forms.collections.abc.sliceable.SliceableForm:

CallBuildsMeaning
.slice(start, stop, step=None)ResultTSlice of self from start to stop, stepping by step.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

Undocumented: example.

NoneAttrRef

An AttrRef with the none interface.

NoneAttrRef(source=None)

Path nu.context.NoneAttrRef. Kind Ref, sort ref, cardinality scalar.

Inherited methods

From nu.context.attrs.refs.AttrRef:

CallBuildsMeaning
.exists()AttrExistsA Query yielding whether this Ref's address is bound in ctx.attrs.

From nu.forms.primitives.none_.None_:

CallBuildsMeaning
.and_(other)BoolLogical AND of self and other.
.or_(other)BoolLogical OR of self and other.
.not_()BoolLogical NOT of self.
.bool_()BoolCast self to Bool.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

Undocumented: example.

SetAttrRef

An AttrRef with the full set interface.

SetAttrRef()

Path nu.context.SetAttrRef. Kind Ref, sort ref, cardinality scalar.

Inherited methods

From nu.context.attrs.refs.AttrRef:

CallBuildsMeaning
.exists()AttrExistsA Query yielding whether this Ref's address is bound in ctx.attrs.

From nu.forms.collections.set_.Set:

CallBuildsMeaning
SetAttrRef.create()Set[T]Build a fresh empty set.
SetAttrRef.of(*items)SetBuild a set from positional item expressions.
a > bBoolSelf is a proper superset of other.
a < bBoolSelf is a proper subset of other.
a >= bBoolSelf is a superset of other, or equal.
a <= bBoolSelf is a subset of other, or equal.
a == bBoolSelf equal to other by value.
a != bBoolSelf not equal to other by value.
.is_(other)BoolIdentity comparison: self is other.

From nu.forms.collections.abc.set_.MutableSetForm:

CallBuildsMeaning
.add(value)AnyAdd value to self.
.remove(value)AnyRemove value from self.
.discard(value)AnyRemove value from self if present.
.pop()ElementResultTRemove and return an arbitrary element from self.
.clear()AnyRemove every element from self.
.update(other)AnyAdd every element of other to self.
.intersection_update(other)AnyKeep only the elements of self also found in other.
.difference_update(other)AnyRemove every element of other from self.
.symmetric_difference_update(other)AnyKeep the elements in exactly one of self and other.

From nu.forms.collections.abc.set_.SetLikeForm:

CallBuildsMeaning
.union(other)CollectionResultTUnion of self and other.
.intersection(other)CollectionResultTIntersection of self and other.
.difference(other)CollectionResultTElements of self that are not in other.
.symmetric_difference(other)CollectionResultTElements in exactly one of self and other, not both.
.issubset(other)BoolWhether every element of self is in other.
.issuperset(other)BoolWhether every element of other is in self.
.isdisjoint(other)BoolWhether self and other share no elements.
.copy()CollectionResultTShallow copy of self.
a | bCollectionResultTUnion: self | other.
a & bCollectionResultTIntersection: self & other.
a - bCollectionResultTDifference: self - other.
a ^ bCollectionResultTSymmetric difference: self ^ other.

From nu.forms.collections.abc.collection.CollectionForm:

CallBuildsMeaning
.extract()objectMaterialise the full subtree rooted at self.

From nu.forms.collections.abc.sized.SizedForm:

CallBuildsMeaning
.len()IntLength of self.

From nu.forms.collections.abc.iterable.IterableForm:

CallBuildsMeaning
iter(a)Iterator[ElementT]Open self into a lazy iterator stream (Python's iter).

From nu.forms.collections.abc.container.ContainerForm:

CallBuildsMeaning
.contains(item)BoolWhether item is a member of self.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

Undocumented: example.

StrAttrRef

An AttrRef with the full string interface.

StrAttrRef()

Path nu.context.StrAttrRef. Kind Ref, sort ref, cardinality scalar.

Inherited methods

From nu.context.attrs.refs.AttrRef:

CallBuildsMeaning
.exists()AttrExistsA Query yielding whether this Ref's address is bound in ctx.attrs.

From nu.forms.primitives.str_.Str:

CallBuildsMeaning
a + bStrConcatenation of self and other.
a[key]StrCharacter at an int index, or substring for a slice.
a > bBoolSelf strictly greater than other, lexicographically.
a < bBoolSelf strictly less than other, lexicographically.
a >= bBoolSelf greater than or equal to other, lexicographically.
a <= bBoolSelf less than or equal to other, lexicographically.
a == bBoolSelf equal to other by value.
a != bBoolSelf not equal to other by value.
.is_(other)BoolIdentity comparison: self is other.
.and_(other)BoolLogical AND of self and other.
.or_(other)BoolLogical OR of self and other.
.not_()BoolLogical NOT of self.
.bool_()BoolCast self to Bool.
.upper()StrSelf converted to uppercase.
.lower()StrSelf converted to lowercase.
.title()StrSelf converted to title case.
.capitalize()StrSelf with only the first character capitalized.
.swapcase()StrSelf with uppercase and lowercase characters swapped.
.casefold()StrSelf folded for aggressive, caseless matching.
.strip(chars=None)StrSelf with leading and trailing characters removed.
.lstrip(chars=None)StrSelf with leading characters removed.
.rstrip(chars=None)StrSelf with trailing characters removed.
.split(sep=None, maxsplit=-1)ListSelf split into a list on sep, from the left.
.rsplit(sep=None, maxsplit=-1)ListSelf split into a list on sep, from the right.
.splitlines(keepends=False)ListSelf split into a list at line boundaries.
.partition(sep)TupleSelf split around the first occurrence of sep into a 3-tuple.
.rpartition(sep)TupleSelf split around the last occurrence of sep into a 3-tuple.
.find(sub, start=0, end=None)IntLowest index in self where sub is found, searching from the left.
.rfind(sub, start=0, end=None)IntHighest index in self where sub is found, searching from the right.
.index(sub, start=0, end=None)IntLowest index in self where sub is found, searching from the left.
.rindex(sub, start=0, end=None)IntHighest index in self where sub is found, searching from the right.
.count_substring(sub)IntCount of non-overlapping occurrences of sub in self.
.startswith(prefix)BoolWhether self starts with prefix.
.endswith(suffix)BoolWhether self ends with suffix.
.isdigit()BoolWhether every character in self is a digit.
.isalpha()BoolWhether every character in self is alphabetic.
.isalnum()BoolWhether every character in self is alphanumeric.
.isspace()BoolWhether every character in self is whitespace.
.isnumeric()BoolWhether every character in self is numeric.
.isdecimal()BoolWhether every character in self is a decimal character.
.isidentifier()BoolWhether self is a valid Python identifier.
.isprintable()BoolWhether every character in self is printable.
.istitle()BoolWhether self is titlecased.
.isupper()BoolWhether every cased character in self is uppercase.
.islower()BoolWhether every cased character in self is lowercase.
.isascii()BoolWhether every character in self is ASCII.
.center(width, fillchar=' ')StrSelf centered in a field of the given width.
.ljust(width, fillchar=' ')StrSelf left-justified in a field of the given width.
.rjust(width, fillchar=' ')StrSelf right-justified in a field of the given width.
.zfill(width)StrSelf padded with leading zeros to the given width.
.expandtabs(tabsize=8)StrSelf with tab characters expanded to spaces.
.replace(old, new, count=-1)StrSelf with occurrences of old replaced by new.
.removeprefix(prefix)StrSelf with the given prefix removed if present.
.removesuffix(suffix)StrSelf with the given suffix removed if present.
.translate(table)StrSelf with characters mapped through a translation table.
.format_map(mapping)StrSelf formatted with {field} placeholders filled from mapping.
.encode(encoding='utf-8')BytesSelf encoded to Bytes.
.join(iterable)StrElements of iterable joined together with self as separator.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

Undocumented: example.

TupleAttrRef

An AttrRef with the full tuple interface.

TupleAttrRef()

Path nu.context.TupleAttrRef. Kind Ref, sort ref, cardinality scalar.

Inherited methods

From nu.context.attrs.refs.AttrRef:

CallBuildsMeaning
.exists()AttrExistsA Query yielding whether this Ref's address is bound in ctx.attrs.

From nu.forms.collections.tuple_.Tuple:

CallBuildsMeaning
TupleAttrRef.create()Tuple[Unpack[Ts]]Empty tuple.
TupleAttrRef.of(items)TupleTuple built from positional item expressions.
a + bTupleConcatenation of self and other.
a * bTupleSelf repeated n times.
a > bBoolSelf strictly greater than other, lexicographically.
a < bBoolSelf strictly less than other, lexicographically.
a >= bBoolSelf greater than or equal to other, lexicographically.
a <= bBoolSelf less than or equal to other, lexicographically.
a == bBoolSelf equal to other by value.
a != bBoolSelf not equal to other by value.
.is_(other)BoolIdentity comparison: self is other.

From nu.forms.collections.abc.sequence.SequenceForm:

CallBuildsMeaning
a[key]ElementResultT | CollectionResultTElement at an int index, or subsequence for a slice.
.first_elem()ElementResultTFirst element of self.
.last_elem()ElementResultTLast element of self.
.index(value)IntLowest index in self where value is found, searching from the left.
.count(value)IntCount of occurrences of value in self.
.reversed()CollectionResultTSelf walked back to front, as a stream.

From nu.forms.collections.abc.collection.CollectionForm:

CallBuildsMeaning
.extract()objectMaterialise the full subtree rooted at self.

From nu.forms.collections.abc.sized.SizedForm:

CallBuildsMeaning
.len()IntLength of self.

From nu.forms.collections.abc.iterable.IterableForm:

CallBuildsMeaning
iter(a)Iterator[ElementT]Open self into a lazy iterator stream (Python's iter).

From nu.forms.collections.abc.container.ContainerForm:

CallBuildsMeaning
.contains(item)BoolWhether item is a member of self.

From nu.forms.collections.abc.sliceable.SliceableForm:

CallBuildsMeaning
.slice(start, stop, step=None)ResultTSlice of self from start to stop, stepping by step.

From nu.lang.forms.Form:

CallBuildsMeaning
.is_empty()BoolTrue if this Form yields the EMPTY sentinel.
.is_invalid()BoolTrue if this Form yields the INVALID sentinel.
.is_sentinel()BoolTrue if this Form yields either sentinel (EMPTY or INVALID).
.not_empty()BoolTrue if this Form does not yield EMPTY.
.not_invalid()BoolTrue if this Form does not yield INVALID.

Undocumented: example.

On this page