src/pylib/pybytes/bytesimpl

Search:
Group by:
Source   Edit  

Types

PyBytes = distinct string
Source   Edit  

Procs

func `$`(self: PyBytes): string {.borrow, ...raises: [], tags: [], forbids: [].}
to Nim string Source   Edit  
func `+`(o: char; self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
Source   Edit  
func `+`(o: string; self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
Source   Edit  
func `+`(self: PyBytes; o: char): PyBytes {....raises: [], tags: [], forbids: [].}
Source   Edit  
func `+`(self: PyBytes; o: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
Source   Edit  
func `+`(self: PyBytes; o: string): PyBytes {....raises: [], tags: [], forbids: [].}
Source   Edit  
func `+=`(mself; s: char) {....raises: [], tags: [], forbids: [].}
Source   Edit  
func `+=`(mself; s: PyBytes) {....raises: [], tags: [], forbids: [].}
Source   Edit  
func `+=`(mself; s: string) {....raises: [], tags: [], forbids: [].}
Source   Edit  
func `==`(self: PyBytes; o: PyBytes): bool {.borrow, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
func `@`(self: PyBytes): seq[char] {....raises: [], tags: [], forbids: [].}

EXT.

Python has no concept of seq (though has list)

Source   Edit  
func `[]`(self: PyBytes; i: HSlice[int, BackwardsIndex]): PyBytes {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
func `[]`(self: PyBytes; i: int): int {....raises: [], tags: [], forbids: [].}
Source   Edit  
func `[]`(self: PyBytes; i: Slice[int]): PyBytes {....raises: [], tags: [],
    forbids: [].}
EXT. s[1..2] means s[1:3], and the latter is not valid Nim code Source   Edit  
func byteLen(self: PyBytes): int {....raises: [], tags: [], forbids: [].}
EXT. the same as len(self) Source   Edit  
func bytes(): PyBytes {....raises: [], tags: [], forbids: [].}
Source   Edit  
func bytes(c: char): PyBytes {....raises: [], tags: [], forbids: [].}
Source   Edit  
func bytes(nLen: int): PyBytes {....raises: [], tags: [], forbids: [].}
null bytes of length nLen (a.k.a. b'\0'*nLen) Source   Edit  
func bytes(s: openArray[char]): PyBytes {....raises: [], tags: [], forbids: [].}

EXT.

Python has no concept of openArray

Source   Edit  
func bytes(s: string): PyBytes {....raises: [], tags: [], forbids: [].}
XXX: Currently no encode and errors params Source   Edit  
func bytes(self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
copy Source   Edit  
func bytes(x: Iterable[char]): PyBytes
EXT. as Python has no char type. Source   Edit  
func bytes(x: Iterable[int]): PyBytes
Source   Edit  
func fspath(self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
make a PathLike Source   Edit  
func getChar(self: PyBytes; i: Natural): char {....raises: [], tags: [],
    forbids: [].}
EXT. Source   Edit  
func getCharPtr(self: PyBytes; i: Natural | BackwardsIndex): ptr char
EXT. unstable. used by Lib/array frombytes and tobytes Source   Edit  
func hasChar(a: PyBytes; o: char): bool {....raises: [], tags: [], forbids: [].}
EXT. 'c' in b"asc" is allowed Source   Edit  
func len(self: PyBytes): int {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc substr(self: PyBytes; start, last: int): PyBytes {.borrow, ...raises: [],
    tags: [], forbids: [].}
EXT. byte index Source   Edit  
proc substr(self: PyBytes; start: int): PyBytes {.borrow, ...raises: [], tags: [],
    forbids: [].}
EXT. byte index Source   Edit  

Iterators

iterator chars(self: PyBytes): char {....raises: [], tags: [], forbids: [].}
EXT. Source   Edit  
iterator items(self: PyBytes): int {....raises: [], tags: [], forbids: [].}
Source   Edit  

Converters

converter toNimString(self: PyBytes): string {....raises: [], tags: [], forbids: [].}
Source   Edit  

Templates

template `not`(s: PyBytes): bool

Mimics Python not str -> bool.

"not" for strings, return true if the string is not nil or empty.

Source   Edit  
template `or`(a, b: PyBytes): PyBytes
Mimics Python str or str -> str. Returns a if a is not empty, otherwise b (even if it's empty) Source   Edit  
template pybytes[T](x: T): PyBytes
Source   Edit