Skip to content

B8 (Boolean)

The B8 type represents a boolean value in raypy.

  • Any non-zero integer value is converted to True
  • Any non-empty string is converted to True
  • The B8 type can be used directly in boolean contexts (if statements, etc.)
  • Comparison only works between B8 instances

Type Information

Type Rayforce Object Type Code Size
B8 -1 8 bits

Creating B8 Values

from raypy import types as t

# From boolean values
>>> t.B8(True)
B8(True)

>>> t.B8(False)
B8(False)

>>> t.B8(0)
B8(False)

>>> t.B8(1)
B8(True)

# From string values (any non-empty string = True)
>>> B8("True")
B8(True)

>>> B8("False")  # Note: still True because string is non-empty
B8(True)

Accessing Values

>>> b = t.B8(True)
>>> b
B8(True)
>>> b.value
True

Basic Usage

b = B8(True)

# Use in boolean context
if b:
    print("Value is True")

Comparison

>>> b1 = B8(True)
>>> b2 = B8(True)
>>> b3 = B8(False)
>>> b1 == b2
True

>>> b1 == b3
False

# Comparison by reference only valid if comparing inner values
# (objects are having different memory addresses)
>>> b1 is b2
False

>>> b1.value is b2.value
True