8.2.11.2. Token¶
- class Token(*args)[source]¶
It constructs a unique constant that behaves like a string.
Example:
>>> s = Token('string') >>> s string >>> s == 'string' False >>> s == Token('string') False >>> {s: 1, Token('string'): 1} {string: 1, string: 1} >>> s.capitalize() 'String'
Methods
__add__Return self+value.
__contains__Return key in self.
__copy____deepcopy____delattr__Implement delattr(self, name).
__dir__Default dir() implementation.
__eq__Return self==value.
__format__Return a formatted version of the string as described by format_spec.
__ge__Return self>=value.
__getattribute__Return getattr(self, name).
__getitem__Return self[key].
__getnewargs____getstate__Helper for pickle.
__gt__Return self>value.
__hash__Return hash(self).
__init_subclass__This method is called when a class is subclassed.
__iter__Implement iter(self).
__le__Return self<=value.
__len__Return len(self).
__lt__Return self<value.
__mod__Return self%value.
__mul__Return self*value.
__ne__Return self!=value.
__new____reduce__Helper for pickle.
__reduce_ex__Helper for pickle.
__repr__Return repr(self).
__rmod__Return value%self.
__rmul__Return value*self.
__setattr__Implement setattr(self, name, value).
__sizeof__Return the size of the string in memory, in bytes.
__str__Return str(self).
__subclasshook__Abstract classes can override this to customize issubclass().
capitalizeReturn a capitalized version of the string.
casefoldReturn a version of the string suitable for caseless comparisons.
centerReturn a centered string of length width.
countS.count(sub[, start[, end]]) -> int
encodeEncode the string using the codec registered for encoding.
endswithS.endswith(suffix[, start[, end]]) -> bool
expandtabsReturn a copy where all tab characters are expanded using spaces.
findS.find(sub[, start[, end]]) -> int
formatformat_mapS.format_map(mapping) -> str
indexS.index(sub[, start[, end]]) -> int
isalnumReturn True if the string is an alpha-numeric string, False otherwise.
isalphaReturn True if the string is an alphabetic string, False otherwise.
isasciiReturn True if all characters in the string are ASCII, False otherwise.
isdecimalReturn True if the string is a decimal string, False otherwise.
isdigitReturn True if the string is a digit string, False otherwise.
isidentifierReturn True if the string is a valid Python identifier, False otherwise.
islowerReturn True if the string is a lowercase string, False otherwise.
isnumericReturn True if the string is a numeric string, False otherwise.
isprintableReturn True if the string is printable, False otherwise.
isspaceReturn True if the string is a whitespace string, False otherwise.
istitleReturn True if the string is a title-cased string, False otherwise.
isupperReturn True if the string is an uppercase string, False otherwise.
joinConcatenate any number of strings.
ljustReturn a left-justified string of length width.
lowerReturn a copy of the string converted to lowercase.
lstripReturn a copy of the string with leading whitespace removed.
maketransReturn a translation table usable for str.translate().
partitionPartition the string into three parts using the given separator.
removeprefixReturn a str with the given prefix string removed if present.
removesuffixReturn a str with the given suffix string removed if present.
replaceReturn a copy with all occurrences of substring old replaced by new.
rfindS.rfind(sub[, start[, end]]) -> int
rindexS.rindex(sub[, start[, end]]) -> int
rjustReturn a right-justified string of length width.
rpartitionPartition the string into three parts using the given separator.
rsplitReturn a list of the substrings in the string, using sep as the separator string.
rstripReturn a copy of the string with trailing whitespace removed.
splitReturn a list of the substrings in the string, using sep as the separator string.
splitlinesReturn a list of the lines in the string, breaking at line boundaries.
startswithS.startswith(prefix[, start[, end]]) -> bool
stripReturn a copy of the string with leading and trailing whitespace removed.
swapcaseConvert uppercase characters to lowercase and lowercase characters to uppercase.
titleReturn a version of the string where each word is titlecased.
translateReplace each character in the string using the given translation table.
upperReturn a copy of the string converted to uppercase.
zfillPad a numeric string with zeros on the left, to fill a field of the given width.
- __init__(*args)¶
Attributes
list of weak references to the object
- __annotations__ = {}¶
- __dict__ = mappingproxy({'__module__': 'schedula.utils.gen', '__doc__': "\n It constructs a unique constant that behaves like a string.\n\n Example::\n\n >>> s = Token('string')\n >>> s\n string\n >>> s == 'string'\n False\n >>> s == Token('string')\n False\n >>> {s: 1, Token('string'): 1}\n {string: 1, string: 1}\n >>> s.capitalize()\n 'String'\n ", '__dict__': <attribute '__dict__' of 'Token' objects>, '__weakref__': <attribute '__weakref__' of 'Token' objects>, '__annotations__': {}})¶
- __doc__ = "\n It constructs a unique constant that behaves like a string.\n\n Example::\n\n >>> s = Token('string')\n >>> s\n string\n >>> s == 'string'\n False\n >>> s == Token('string')\n False\n >>> {s: 1, Token('string'): 1}\n {string: 1, string: 1}\n >>> s.capitalize()\n 'String'\n "¶
- __module__ = 'schedula.utils.gen'¶
- __weakref__¶
list of weak references to the object