src/pylib/pybool

Source   Edit  

Types

PyBool = distinct bool
Source   Edit  

Consts

False = false
False Source   Edit  
True = true
True Source   Edit  

Procs

func `$`(self: PyBool): string {....raises: [], tags: [], forbids: [].}

alias for repr

NOTE: CPython's bool's __str__ is itself not defined, which is inherted from object, which will call obj.__repr__ as fallback. This minics it.

Source   Edit  
func `==`(b: bool; self: PyBool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func `==`(self: PyBool; b: bool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func `==`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func all[T](iter: Iterable[T]): PyBool
Checks if all values in iterable are truthy Source   Edit  
func `and`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func `and`[T: not PyBool and not bool](nself, npyb: T): T
Source   Edit  
func any[T](iter: Iterable[T]): PyBool
Checks if at least one value in iterable is truthy Source   Edit  
proc bool[T](arg: T): PyBool
Alias for pybool Source   Edit  
func `is`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func `not`(self: PyBool): PyBool {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
func `not`[T: not PyBool and not bool](nself: T): PyBool
Source   Edit  
func `or`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func `or`[T: not PyBool and not bool](nself, npyb: T): T
Source   Edit  
func repr(self: PyBool): string {....raises: [], tags: [], forbids: [].}
Returns "True" or "False" Source   Edit  
func `xor`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
EXT Source   Edit  

Converters

converter pybool(x: bool): PyBool {....raises: [], tags: [], forbids: [].}
Source   Edit  
converter pybool[T](x: T): PyBool
Source   Edit  
converter toNimBool(self: PyBool): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  

Templates

template toBool[T](arg: T): bool
Converts argument to boolean, checking python-like truthiness. Source   Edit