Title: Theory / Unimportant / CS / Programming / Python / Lib / built-in types / str
Tags: computer_to_instruction automatedNewLineAfterCommaSpace
On every note of this deck, unless a note says otherwise:
Page: https://docs.python.org/3.7/library/stdtypes.html#text-sequence-type-str
Language: Python

Instruction: s.capitalize()
Returns: a copy of the string with its first character capitalized and the rest lowercased.
Variables: s a string

Instruction: s.casefold()
Returns: A casefolded copy of the string, as by Unicode standard
Variables: s a string
Example: ß becomes ss

Instruction: s.center(width,fillchar = " ")
Returns: A string of length width, with s in the center, and fillchar around.
Or original string if width<=len(s)
Variables: s a string

Instruction: s.count(sub,start=0,end=-1)
Returns: Number of non-overlapping copy of sub in s[start:end]
Variables: s a string

Instruction: s.encode(encoding="utf-8",errors="strict")
Returns: An encoded version of the string as a bytes object.
Variables: s a string

Instruction: s.endswith(
  suffix,
  start=0,
  end=-1
)
Returns: Whether s[start:end] end with the string suffix
Variables: s a string
suffix a string

Instruction: s.endswith(
  suffixes,
  start=0,
  end=-1
)
Returns: Whether s[start:end] end with a string belonging to suffix
Variables: s a string
suffixes a tuple of string

Instruction: s.expandtabs(tabsize=8)
Returns: A copy of s where each tabs are replaced by 1 to tabsize spaces such that the letter after the tab is at a position which is a multiple of tabsize
Variables: s a string

Instruction: s.index(sub,start=0,end=-1)
Returns: Lowest index i at least start, less than end such that the string at position i equals sub.
Variables: s a string
Exception: ValueError if there is no such index

Instruction: s.find(sub,start=0,end=-1)
Returns: Lowest index i at least start, less than end such that the string at position i equals sub. -1 if such a position does not exists.
Variables: s a string

Instruction: s.format_map(m)
Returns: Similar to s.format(**m), but no dictionnary is created, m is directly used
Variables: s a string

Instruction: s.isalnum()
Returns: Whether all characters in the string are alphanumeric and there is at least one character
Variables: s a string

Instruction: s.isalpha()
Returns: Whether all characters in the string are alphabetic (Letter in unicode character database) and there is at least one character.
Variables: s a string

Instruction: s.isdigit()
Returns: Whether all characters in the string are digits and there is at least one character.
Variables: s a string

Instruction: s.isdecimal()
Returns: Whether all characters in the string are decimal characters and there is at least one character.
Variables: s a string

Question: Difference between isdigit and isdecimal
Answer: Digit includes Kharoshti numbers, and compatibility superscripts digits, for example.
Page: https://docs.python.org/3.7/library/stdtypes.html#text-sequence-type-str
Variables: s a string

Instruction: s.isidentifier()
Returns: Whether the string is a valid identifier according to the language definition
Variables: s a string

Instruction: s.islower()
Returns: Whether all cased character are lower case and there is a cased character
Variables: s a string

Instruction: s.isnumeric()
Returns: Whether all characters are numeric characters (cacording to unicode) and there is at least one character.
Variables: s a string

Instruction: s.isprintable()
Returns: Whether string all characters in the strings are printable or space. (i.e. not other or separator in Unicode, )
Variables: s a string

Instruction: s.isspace()
Returns: Whether its non empty and contains only whitespace
Variables: s a string

Instruction: s.istitle()
Returns: Whether string is titlecased and non-empty
Variables: s a string

Instruction: s.isupper()
Returns: Whether all cased character are uppercase, and there is a cased character
Variables: s a string

Instruction: s.join(iter)
Returns: A string which is the concatenation of the strings in iter
Variables: s a string

Instruction: s.rjust(
  width,
  fillchar=" "
)
Returns: A string of length width beginning with s, with left filled by fillchar.
Or s if width <= len(  s)
Variables: s a string

Instruction: s.ljust(
  width,
  fillchar=" "
)
Returns: A string of length width ending with s, with left filled by fillchar.
Or s if width <= len(  s)
Variables: s a string

Instruction: s.lower()
Returns: A copy of the string with all the cased characters converted to lowercase as in unicode standard
Variables: s a string

Instruction: s.lstrip(chars=" ")
Returns: A copy of s where the longest prefix containing only characters of chars is removed
Variables: s a string

Instruction: str.maketrans(map)
Returns: A translation table usable for str.translate(), translating keys of m (which are unicode ordinal or characters) to Unicode ordinal, strings or None
Variables: s a string

Instruction: str.maketrans(x,y)
Returns: A translation table usable for str.translate(), translating keys x[i] to y[i]
Variables: s a string
Assuming: x and y of same length

Instruction: str.maketrans(x,y,z)
Returns: A translation table usable for str.translate(), translating keys x[i] to y[i] and elements of z to Null
Variables: s a string
Assuming: x and y of same length

Instruction: s.rpartition(sep)
Returns: if sep in s then:(pre,sep,suf) with pre+sep+suf=s, and suf not containing sep.
(s,"","") otherwise
Variables: s a string

Instruction: s.partition(sep)
Returns: if sep in s then:(pre,sep,suf) with pre+sep+suf=s, and pre not containing sep.
(s,"","") otherwise
Variables: s a string

Instruction: s.replace(old,new)
Returns: A copy of s with each occurence of old in s replaced by new
Variables: s a string

Instruction: s.replace(old,new,count)
Returns: A copy of s where the first count occurence of old in s are replaced by new
Variables: s a string

Instruction: s.rfind(sub,start=0,end=-1)
Returns: highest index in the string where substring sub is found, such that sub is contained within s[start:end].
-1 on failure
Variables: s a string

Instruction: s.rindex(sub,start=0,end=-1)
Returns: highest index in the string where substring sub is found, such that sub is contained within s[start:end].
Variables: s a string
Exception: ValueError if sub is not found

Instruction: s.rsplit(sep=None ,maxsplit=-1)
Returns: Similar to s.split(sep=None ,maxsplit=-1), but splitting on the right
Variables: s a string

Instruction: s.strip(chars = " ")
Returns: Copy of s with the longest prefix and suffix containing only elements of chars removed
Variables: s a string

Instruction: s.rstrip(chars = " ")
Returns: Similar to s.strip(chars), but stripping on the right
Variables: s a string

Instruction: s.split(
  sep = None,
  maxsplit = -1
)
Returns: Return a list [a_0,...,a_n] of at least maxsplit+1(  arbitrary size by default) elements such that a_0+sep_1'+...+sep'_n+a_n=s. With sep'_i being sep if sep is not None, or a non-empty sequence of whitespace otherwise. The a_i's does not contain sep, except for a_n if n=maxsplit.
Variables: s a string

Instruction: s.splitlines(keepends=False)
Returns: Split according to any new line separator. Keep the newline in the strings if keepends is True
Variables: s a string

Instruction: s.startwith(
  prefix,
  start=0,end=-1
)
Returns: Whether s[start:end] starts with prefix
Variables: s a string

Instruction: s.swapcase()
Returns: A copy of s with case of cased characters inversed
Variables: s a string

Instruction: s.title()
Returns: A titlecased version of s
Variables: s a string

Instruction: s.translate(table)
Returns: A copy of s where replacement of characters are made according to table.
Variables: s a string

Instruction: s.upper()
Returns: A copy of s where all cased character are converted to uppercase
Variables: s a string

Instruction: s.zfill(width)
Returns: A copy of s, of length width, left-filled with 0. If the first char is + or -, it remains the first char.
Return s if len(s)>=width
Variables: s a string