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`(b: bool; self: PyBool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func `and`(self: PyBool; b: bool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func `and`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func `and`[T](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](nself: T): PyBool
Source   Edit  
func `or`(b: bool; self: PyBool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func `or`(self: PyBool; b: bool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func `or`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func `or`[T](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

Converts any to PyBool

NOTE: In Nim, "implicit converter chain is not support". (See manual.html). Therefore any type can be implicitly converted to PyBool, not bool, which, however, is desired, as if any is convertible to bool, then there'll be ## compile-error for repr(<list>)

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