Procs
func capitalize(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
-
make the first character have title/upper case and the rest lower case.
changed when Python 3.8: the first character will have title case.
while Nim's unicode.capitalize only make the first character upper-case.
Source Edit func casefold(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
-
Admonition: since Python 3.3
str.casefold()
str.lower() is used for most characters, but, for example, Cherokee letters is casefolded to their uppercase counterparts, and some will be converted to their normal case, e.g. "Γ" -> "ss"
Source Edit func expandtabs(a: PyStr; tabsize = 8): PyStr {....raises: [], tags: [], forbids: [].}
- Source Edit
func lower(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
-
str.lower
not the same as Nim's unicode.toLower, see examples
Example:
import std/unicode let dotI = Rune 0x0130 # Δ° (LATIN CAPITAL LETTER I WITH DOT ABOVE) assert str(dotI).lower() == "i\u0307" ## iΜ (\u0207 is a upper dot) assert dotI.toLower() == Rune('i')
Source Edit func startsWith(a: char; suffix: PyStr): bool {....raises: [], tags: [], forbids: [].}
- Source Edit
func startsWith(a: PyStr; suffix: char): bool {....raises: [], tags: [], forbids: [].}
- Source Edit
func startsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start, end: int): bool
- Source Edit
func startsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start: int): bool
- Source Edit
func startsWith[Tup: tuple](a: PyStr; suffix: Tup): bool
- Source Edit
func upper(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
-
str.upper
not the same as Nim's unicode.toUpper, see examples
Example:
import std/unicode let a = "αΎ·" # GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI assert str(a).upper() == "ΞΝΞ" # 3 chars assert a.toUpper() == a # Nim just maps it as-is. # There is more examples... (101 characters in total)
Source Edit