Package org.python.core

# Class PyString

java.lang.Object
org.python.core.PyObject
org.python.core.PySequence
org.python.core.PyBaseString
org.python.core.PyString

All Implemented Interfaces:
  `Serializable`, `CharSequence`, `BufferProtocol`

Direct Known Subclasses:
  `PyShadowString`, `PyStringDerived`, `PyUnicode`, `SyspathArchive`

public class PyString extends PyBaseString implements BufferProtocol
A builtin python string.

See Also:
  - Serialized Form

## Nested Class Summary

## Nested classes/interfaces inherited from class org.python.core.PyObject

`PyObject.ConversionException`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final PyType`
`TYPE`

### Fields inherited from class org.python.core.PyObject

`gcMonitorGlobal`

## Constructor Summary

Constructors
Constructor
Description
`PyString()`
`PyString(char c)`
`PyString(String string)`
`PyString(PyType subType, String string)`
Fundamental constructor for `PyString` objects when the client provides a Java `String`, necessitating that we range check the characters.

## Method Summary

Modifier and Type
Method
Description
`PyObject`
`__add__(PyObject other)`
Equivalent to the standard Python __add__ method.
`int`
`__cmp__(PyObject other)`
Equivalent to the standard Python __cmp__ method.
`PyComplex`
`__complex__()`
Equivalent to the standard Python __complex__ method.
`boolean`
`__contains__(PyObject o)`
Equivalent to the standard Python __contains__ method.
`PyObject`
`__eq__(PyObject other)`
Equivalent to the standard Python __eq__ method.
`PyFloat`
`__float__()`
Equivalent to the standard Python __float__ method.
`PyObject`
`__format__(PyObject formatSpec)`
`PyObject`
`__ge__(PyObject other)`
Equivalent to the standard Python __ge__ method.
`PyTuple`
`__getnewargs__()`
`PyObject`
`__gt__(PyObject other)`
Equivalent to the standard Python __gt__ method.
`PyObject`
`__int__()`
Equivalent to the standard Python __int__ method.
`PyObject`
`__invert__()`
Equivalent to the standard Python __invert__ method.
`PyObject`
`__le__(PyObject other)`
Equivalent to the standard Python __le__ method.
`int`
`__len__()`
Equivalent to the standard Python __len__ method.
`PyObject`
`__long__()`
Equivalent to the standard Python __long__ method.
`PyObject`
`__lt__(PyObject other)`
Equivalent to the standard Python __lt__ method.
`PyObject`
`__mod__(PyObject other)`
Equivalent to the standard Python __mod__ method
`PyObject`
`__mul__(PyObject o)`
Equivalent to the standard Python __mul__ method.
`PyObject`
`__ne__(PyObject other)`
Equivalent to the standard Python __ne__ method.
`PyObject`
`__neg__()`
Equivalent to the standard Python __neg__ method.
`PyObject`
`__pos__()`
Equivalent to the standard Python __pos__ method.
`PyString`
`__repr__()`
Equivalent to the standard Python `__repr__` method.
`PyObject`
`__rmul__(PyObject o)`
Equivalent to the standard Python __rmul__ method.
`PyString`
`__str__()`
Equivalent to the standard Python __str__ method.
`Object`
`__tojava__(Class<?> c)`
Equivalent to the Jython __tojava__ method.
`PyUnicode`
`__unicode__()`
`double`
`asDouble()`
Convert this object into a double.
`int`
`asInt()`
Convert this object into an int.
`long`
`asLong()`
Convert this object into a long.
`String`
`asName(int index)`
`String`
`asString()`
`String`
`asString(int index)`
`double`
`atof()`
Convert this PyString to a floating-point value according to Python rules.
`int`
`atoi()`
`int`
`atoi(int base)`
`PyLong`
`atol()`
`PyLong`
`atol(int base)`
`String`
`capitalize()`
`String`
`center(int width)`
`char`
`charAt(int index)`
`int`
`count(String sub)`
Equivalent to `count(PyObject)` specialized to `String`.
`int`
`count(String sub, PyObject start)`
Equivalent to `count(PyObject, PyObject)` specialized to `String`.
`int`
`count(String sub, PyObject start, PyObject end)`
Equivalent to `count(PyObject, PyObject, PyObject)` specialized to `String` .
`int`
`count(PyObject sub)`
Return the number of non-overlapping occurrences of substring `sub`.
`int`
`count(PyObject sub, PyObject start)`
Return the number of non-overlapping occurrences of substring `sub` in the range `[start:]`.
`int`
`count(PyObject sub, PyObject start, PyObject end)`
Return the number of non-overlapping occurrences of substring `sub` in the range `[start:end]`.
`PyString`
`createInstance(String str)`
Create an instance of the same type as this object, from the Java String given as argument.
`PyObject`
`decode()`
`PyObject`
`decode(String encoding)`
`PyObject`
`decode(String encoding, String errors)`
`static String`
`decode_UnicodeEscape(String str, int start, int end, String errors, boolean unicode)`
`String`
`encode()`
`String`
`encode(String encoding)`
`String`
`encode(String encoding, String errors)`
`static String`
`encode_UnicodeEscape(String str, boolean use_quotes)`
`boolean`
`endswith(PyObject suffix)`
Equivalent to the Python `str.endswith` method, testing whether a string ends with a specified suffix.
`boolean`
`endswith(PyObject suffix, PyObject start)`
Equivalent to the Python `str.endswith` method, testing whether a string ends with a specified suffix, where a sub-range is specified by `[start:]`.
`boolean`
`endswith(PyObject suffix, PyObject start, PyObject end)`
Equivalent to the Python `str.endswith` method, testing whether a string ends with a specified suffix, where a sub-range is specified by `[start:end]`.
`String`
`expandtabs()`
`String`
`expandtabs(int tabsize)`
`int`
`find(String sub)`
Equivalent to `find(PyObject)` specialized to `String`.
`int`
`find(String sub, PyObject start)`
Equivalent to `find(PyObject, PyObject)` specialized to `String`.
`int`
`find(String sub, PyObject start, PyObject end)`
Equivalent to `find(PyObject, PyObject, PyObject)` specialized to `String`.
`int`
`find(PyObject sub)`
Return the lowest index in the string where substring `sub` is found.
`int`
`find(PyObject sub, PyObject start)`
Return the lowest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:]`.
`int`
`find(PyObject sub, PyObject start, PyObject end)`
Return the lowest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:end]`.
`static PyString`
`fromInterned(String interned)`
Creates a `PyString` from an already interned `String` representing bytes.
`PyBuffer`
`getBuffer(int flags)`
Return a read-only buffer view of the contents of the string, treating it as a sequence of unsigned bytes.
`int`
`getInt(int i)`
`String`
`getString()`
`int`
`hashCode()`
`int`
`index(String sub)`
Equivalent to `index(PyObject)` specialized to `String`.
`int`
`index(String sub, PyObject start)`
Equivalent to `index(PyObject, PyObject)` specialized to `String`.
`int`
`index(String sub, PyObject start, PyObject end)`
Equivalent to `index(PyObject, PyObject, PyObject)` specialized to `String` .
`int`
`index(PyObject sub)`
Return the lowest index in the string where substring `sub` is found.
`int`
`index(PyObject sub, PyObject start)`
Return the lowest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:]`.
`int`
`index(PyObject sub, PyObject start, PyObject end)`
Return the lowest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:end]`.
`String`
`internedString()`
`boolean`
`isalnum()`
`boolean`
`isalpha()`
`boolean`
`isBasicPlane()`
Determine whether the string consists entirely of basic-plane characters.
`boolean`
`isdecimal()`
`boolean`
`isdigit()`
`boolean`
`islower()`
`boolean`
`isnumeric()`
`boolean`
`isspace()`
`boolean`
`istitle()`
`boolean`
`isunicode()`
`boolean`
`isupper()`
`PyString`
`join(PyObject seq)`
`int`
`length()`
`String`
`ljust(int width)`
`String`
`ljust(int width, String padding)`
`String`
`lower()`
`String`
`lstrip()`
Equivalent of Python `str.lstrip()` with no argument, meaning strip whitespace.
`String`
`lstrip(String stripChars)`
Equivalent of Python `str.lstrip()`.
`PyObject`
`lstrip(PyObject stripChars)`
Equivalent of Python `str.lstrip()`.
`PyTuple`
`partition(PyObject sepObj)`
Equivalent to Python `str.partition()`, splits the `PyString` at the first occurrence of `sepObj` returning a `PyTuple` containing the part before the separator, the separator itself, and the part after the separator.
`PyString`
`replace(PyObject oldPiece, PyObject newPiece)`
Equivalent to Python str.replace(old, new), returning a copy of the string with all occurrences of substring old replaced by new.
`PyString`
`replace(PyObject oldPiece, PyObject newPiece, int count)`
Equivalent to Python str.replace(old, new[, count]), returning a copy of the string with all occurrences of substring old replaced by new.
`int`
`rfind(String sub)`
Equivalent to `find(PyObject)` specialized to `String`.
`int`
`rfind(String sub, PyObject start)`
Equivalent to `find(PyObject, PyObject)` specialized to `String`.
`int`
`rfind(String sub, PyObject start, PyObject end)`
Equivalent to `find(PyObject, PyObject, PyObject)` specialized to `String`.
`int`
`rfind(PyObject sub)`
Return the highest index in the string where substring `sub` is found.
`int`
`rfind(PyObject sub, PyObject start)`
Return the highest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:]`.
`int`
`rfind(PyObject sub, PyObject start, PyObject end)`
Return the highest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:end]`.
`int`
`rindex(String sub)`
Equivalent to `rindex(PyObject)` specialized to `String`.
`int`
`rindex(String sub, PyObject start)`
Equivalent to `rindex(PyObject, PyObject)` specialized to `String`.
`int`
`rindex(String sub, PyObject start, PyObject end)`
Equivalent to `rindex(PyObject, PyObject, PyObject)` specialized to `String`.
`int`
`rindex(PyObject sub)`
Return the highest index in the string where substring `sub` is found.
`int`
`rindex(PyObject sub, PyObject start)`
Return the highest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:]`.
`int`
`rindex(PyObject sub, PyObject start, PyObject end)`
Return the highest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:end]`.
`String`
`rjust(int width)`
`PyTuple`
`rpartition(PyObject sepObj)`
Equivalent to Python `str.rpartition()`, splits the `PyString` at the last occurrence of `sepObj` returning a `PyTuple` containing the part before the separator, the separator itself, and the part after the separator.
`PyList`
`rsplit()`
Equivalent to Python `str.rsplit()`, splitting on runs of whitespace.
`PyList`
`rsplit(String sep)`
Equivalent to Python `str.rsplit()`, splitting on a specified string.
`PyList`
`rsplit(String sep, int maxsplit)`
Equivalent to Python `str.rsplit()`, splitting on a specified string.
`PyList`
`rsplit(PyObject sep)`
Equivalent to Python `str.rsplit()` returning a `PyList` of `PyString`s (or `PyUnicode`s).
`PyList`
`rsplit(PyObject sep, int maxsplit)`
As `rsplit(PyObject)` but if `maxsplit` >=0 and there are more feasible splits than `maxsplit` the last element of the list contains the rest of the string.
`String`
`rstrip()`
Equivalent of Python `str.rstrip()` with no argument, meaning strip whitespace.
`String`
`rstrip(String stripChars)`
Equivalent of Python `str.rstrip()`.
`PyObject`
`rstrip(PyObject stripChars)`
Equivalent of Python `str.rstrip()`.
`PyList`
`split()`
Equivalent to Python `str.split()`, splitting on runs of whitespace.
`PyList`
`split(String sep)`
Equivalent to Python `str.split()`, splitting on a specified string.
`PyList`
`split(String sep, int maxsplit)`
Equivalent to Python `str.split()`, splitting on a specified string.
`PyList`
`split(PyObject sep)`
Equivalent to Python `str.split()` returning a `PyList` of `PyString`s (or `PyUnicode`s).
`PyList`
`split(PyObject sep, int maxsplit)`
As `split(PyObject)` but if `maxsplit` >=0 and there are more feasible splits than `maxsplit`, the last element of the list contains the rest of the string.
`PyList`
`splitlines()`
`PyList`
`splitlines(boolean keepends)`
`boolean`
`startswith(PyObject prefix)`
Equivalent to the Python `str.startswith` method testing whether a string starts with a specified prefix.
`boolean`
`startswith(PyObject prefix, PyObject start)`
Equivalent to the Python `str.startswith` method, testing whether a string starts with a specified prefix, where a sub-range is specified by `[start:]`.
`boolean`
`startswith(PyObject prefix, PyObject start, PyObject end)`
Equivalent to the Python `str.startswith` method, testing whether a string starts with a specified prefix, where a sub-range is specified by `[start:end]`.
`PyObject`
`str___mod__(PyObject other)`
`String`
`strip()`
Equivalent of Python `str.strip()` with no argument, meaning strip whitespace.
`String`
`strip(String stripChars)`
Equivalent of Python `str.strip()`.
`PyObject`
`strip(PyObject stripChars)`
Equivalent of Python `str.strip()`.
`CharSequence`
`subSequence(int start, int end)`
`String`
`substring(int start, int end)`
Return a substring of this object as a Java String.
`String`
`swapcase()`
`String`
`title()`
`byte[]`
`toBytes()`
`int[]`
`toCodePoints()`
`String`
`toString()`
`String`
`translate(String table)`
Equivalent to `translate(PyObject)` specialized to `String`.
`String`
`translate(String table, String deletechars)`
Equivalent to `translate(PyObject, PyObject)` specialized to `String`.
`String`
`translate(PyObject table)`
Equivalent to Python `str.translate` returning a copy of this string where the characters have been mapped through the translation `table`.
`String`
`translate(PyObject table, PyObject deletechars)`
Equivalent to Python `str.translate` returning a copy of this string where all characters (bytes) occurring in the argument `deletechars` are removed (if it is not `null`), and the remaining characters have been mapped through the translation `table`.
`String`
`upper()`
`String`
`zfill(int width)`

### Methods inherited from class org.python.core.PySequence

`__delitem__, __delslice__, __finditem__, __finditem__, __getitem__, __getslice__, __iter__, __nonzero__, __setitem__, __setitem__, __setslice__, isMappingType, isNumberType, isSequenceType`

### Methods inherited from class org.python.core.PyObject

`__abs__, __and__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __coerce__, __coerce_ex__, __delattr__, __delattr__, __delete__, __delitem__, __delslice__, __dir__, __div__, __divmod__, __ensure_finalizer__, __findattr__, __findattr__, __findattr_ex__, __finditem__, __floordiv__, __get__, __getattr__, __getattr__, __getitem__, __getslice__, __hash__, __hex__, __iadd__, __iand__, __idiv__, __idivmod__, __ifloordiv__, __ilshift__, __imod__, __imul__, __index__, __ior__, __ipow__, __irshift__, __isub__, __iternext__, __itruediv__, __ixor__, __lshift__, __not__, __oct__, __or__, __pow__, __pow__, __radd__, __rand__, __rdiv__, __rdivmod__, __reduce__, __reduce_ex__, __reduce_ex__, __rfloordiv__, __rlshift__, __rmod__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __set__, __setattr__, __setattr__, __setitem__, __setslice__, __sub__, __truediv__, __trunc__, __xor__, _add, _and, _callextra, _cmp, _div, _divmod, _doget, _doget, _doset, _eq, _floordiv, _ge, _gt, _iadd, _iand, _idiv, _idivmod, _ifloordiv, _ilshift, _imod, _imul, _in, _ior, _ipow, _irshift, _is, _isnot, _isub, _itruediv, _ixor, _jcall, _jcallexc, _jthrow, _le, _lshift, _lt, _mod, _mul, _ne, _notin, _or, _pow, _rshift, _sub, _truediv, _xor, asIndex, asIndex, asInt, asIterable, asLong, asName, asStringOrNull, asStringOrNull, bit_length, conjugate, delDict, delType, dispatch__init__, equals, fastGetClass, fastGetDict, getDict, getType, implementsDescrDelete, implementsDescrGet, implementsDescrSet, invoke, invoke, invoke, invoke, invoke, invoke, isCallable, isDataDescr, isIndex, isInteger, noAttributeError, object___subclasshook__, readonlyAttributeError, setDict, setType`

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.lang.CharSequence

`chars, codePoints, isEmpty`

## Field Details

### TYPE

public static final PyType TYPE

## Constructor Details

### PyString

public PyString()

### PyString

public PyString(PyType subType, String string)
Fundamental constructor for `PyString` objects when the client provides a Java `String`, necessitating that we range check the characters.

Parameters:
  `subType` - the actual type being constructed
  `string` - a Java String to be wrapped

### PyString

public PyString(String string)

### PyString

public PyString(char c)

## Method Details

### getString

public String getString()

### fromInterned

public static PyString fromInterned(String interned)
Creates a `PyString` from an already interned `String` representing bytes. The caller guarantees that the character codes are all < 256. (The method is used frequently from compiled code, and with identifiers, where this is guaranteed.) Just means it won't be re-interned if used in a place that requires interned Strings.

Parameters:
  `interned` - `String` representing bytes
Returns:
  `PyString` for those bytes

### isBasicPlane

public boolean isBasicPlane()
Determine whether the string consists entirely of basic-plane characters. For a `PyString`, of course, it is always `true`, but this is useful in cases where either a `PyString` or a `PyUnicode` is acceptable.

Returns:
  true

### toCodePoints

public int[] toCodePoints()

### getBuffer

public PyBuffer getBuffer(int flags)
Return a read-only buffer view of the contents of the string, treating it as a sequence of unsigned bytes. The caller specifies its requirements and navigational capabilities in the `flags` argument (see the constants in interface `PyBUF` for an explanation). The method may return the same PyBuffer object to more than one consumer.

Specified by:
  `getBuffer` in interface `BufferProtocol`
Parameters:
  `flags` - consumer requirements
Returns:
  the requested buffer

### substring

public String substring(int start, int end)
Return a substring of this object as a Java String.

Parameters:
  `start` - the beginning index, inclusive.
  `end` - the ending index, exclusive.
Returns:
  the specified substring.

### __str__

public PyString __str__()
Description copied from class: `PyObject`
Equivalent to the standard Python __str__ method. The default implementation (in `PyObject`) calls `PyObject.__repr__()`, making it unnecessary to override `__str__` in sub-classes of `PyObject` where both forms are the same. A common choice is to provide the same implementation to `__str__` and `toString`, for consistency in the printed form of objects between Python and Java.

Overrides:
  `__str__` in class `PyObject`

### __unicode__

public PyUnicode __unicode__()

Overrides:
  `__unicode__` in class `PyObject`

### __len__

public int __len__()
Description copied from class: `PyObject`
Equivalent to the standard Python __len__ method. Part of the mapping discipline.

Overrides:
  `__len__` in class `PyObject`
Returns:
  the length of the object

### toString

public String toString()

Specified by:
  `toString` in interface `CharSequence`
Overrides:
  `toString` in class `PyObject`

### internedString

public String internedString()

### __repr__

public PyString __repr__()
Description copied from class: `PyObject`
Equivalent to the standard Python `__repr__` method. Each sub-class of `PyObject` is likely to re-define this method to provide for its own reproduction.

Overrides:
  `__repr__` in class `PyObject`

### encode_UnicodeEscape

public static String encode_UnicodeEscape(String str, boolean use_quotes)

### decode_UnicodeEscape

public static String decode_UnicodeEscape(String str, int start, int end, String errors, boolean unicode)

### __cmp__

public int __cmp__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __cmp__ method.

Overrides:
  `__cmp__` in class `PyObject`
Parameters:
  `other` - the object to compare this with.
Returns:
  -1 if `this<o`; 0 if `this==o`; +1 if `this>o`; -2 if no comparison is implemented

### __eq__

public PyObject __eq__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __eq__ method.

Overrides:
  `__eq__` in class `PySequence`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

### __ne__

public PyObject __ne__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __ne__ method.

Overrides:
  `__ne__` in class `PySequence`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

### __lt__

public PyObject __lt__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __lt__ method.

Overrides:
  `__lt__` in class `PySequence`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

### __le__

public PyObject __le__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __le__ method.

Overrides:
  `__le__` in class `PySequence`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

### __gt__

public PyObject __gt__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __gt__ method.

Overrides:
  `__gt__` in class `PySequence`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

### __ge__

public PyObject __ge__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __ge__ method.

Overrides:
  `__ge__` in class `PySequence`
Parameters:
  `other` - the object to compare this with.
Returns:
  the result of the comparison.

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `PyObject`

### toBytes

public byte[] toBytes()

Returns:
  a byte array with one byte for each char in this object's underlying String. Each byte contains the low-order bits of its corresponding char.

### __tojava__

public Object __tojava__(Class<?> c)
Description copied from class: `PyObject`
Equivalent to the Jython __tojava__ method. Tries to coerce this object to an instance of the requested Java class. Returns the special object `Py.NoConversion` if this `PyObject` can not be converted to the desired Java class.

Overrides:
  `__tojava__` in class `PySequence`
Parameters:
  `c` - the Class to convert this `PyObject` to.

### getInt

public int getInt(int i)

### createInstance

public PyString createInstance(String str)
Create an instance of the same type as this object, from the Java String given as argument. This is to be overridden in a subclass to return its own type.

Parameters:
  `str` - to wrap
Returns:
  instance wrapping `str`

### __contains__

public boolean __contains__(PyObject o)
Description copied from class: `PyObject`
Equivalent to the standard Python __contains__ method.

Overrides:
  `__contains__` in class `PyObject`
Parameters:
  `o` - the element to search for in this container.
Returns:
  the result of the search.

### __mul__

public PyObject __mul__(PyObject o)
Description copied from class: `PyObject`
Equivalent to the standard Python __mul__ method.

Overrides:
  `__mul__` in class `PyObject`
Parameters:
  `o` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the mul, or null if this operation is not defined

### __rmul__

public PyObject __rmul__(PyObject o)
Description copied from class: `PyObject`
Equivalent to the standard Python __rmul__ method.

Overrides:
  `__rmul__` in class `PyObject`
Parameters:
  `o` - the object to perform this binary operation with (the left-hand operand).
Returns:
  the result of the mul, or null if this operation is not defined.

### __add__

public PyObject __add__(PyObject other)
Equivalent to the standard Python __add__ method. For a `str` addition means concatenation and returns a `str` (`PyString`) result, except when a `PyUnicode` argument is given, when a `PyUnicode` results.

Overrides:
  `__add__` in class `PyObject`
Parameters:
  `other` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the add, or null if this operation is not defined.

### __getnewargs__

public PyTuple __getnewargs__()

Overrides:
  `__getnewargs__` in class `PyObject`

### __mod__

public PyObject __mod__(PyObject other)
Description copied from class: `PyObject`
Equivalent to the standard Python __mod__ method

Overrides:
  `__mod__` in class `PyObject`
Parameters:
  `other` - the object to perform this binary operation with (the right-hand operand).
Returns:
  the result of the mod, or null if this operation is not defined

### str___mod__

public PyObject str___mod__(PyObject other)

### __int__

public PyObject __int__()
Description copied from class: `PyObject`
Equivalent to the standard Python __int__ method. Should only be overridden by numeric objects that can be reasonably coerced into an integer.

Overrides:
  `__int__` in class `PyObject`
Returns:
  an integer corresponding to the value of this object.

### __long__

public PyObject __long__()
Description copied from class: `PyObject`
Equivalent to the standard Python __long__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python long.

Overrides:
  `__long__` in class `PyObject`
Returns:
  a PyLong or PyInteger corresponding to the value of this object.

### __float__

public PyFloat __float__()
Description copied from class: `PyObject`
Equivalent to the standard Python __float__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python float.

Overrides:
  `__float__` in class `PyObject`
Returns:
  a float corresponding to the value of this object.

### __pos__

public PyObject __pos__()
Description copied from class: `PyObject`
Equivalent to the standard Python __pos__ method.

Overrides:
  `__pos__` in class `PyObject`
Returns:
  +this.

### __neg__

public PyObject __neg__()
Description copied from class: `PyObject`
Equivalent to the standard Python __neg__ method.

Overrides:
  `__neg__` in class `PyObject`
Returns:
  -this.

### __invert__

public PyObject __invert__()
Description copied from class: `PyObject`
Equivalent to the standard Python __invert__ method.

Overrides:
  `__invert__` in class `PyObject`
Returns:
  ~this.

### __complex__

public PyComplex __complex__()
Description copied from class: `PyObject`
Equivalent to the standard Python __complex__ method. Should only be overridden by numeric objects that can be reasonably coerced into a python complex number.

Overrides:
  `__complex__` in class `PyObject`
Returns:
  a complex number corresponding to the value of this object.

### lower

public String lower()

### upper

public String upper()

### title

public String title()

### swapcase

public String swapcase()

### strip

public String strip()
Equivalent of Python `str.strip()` with no argument, meaning strip whitespace. Any whitespace byte/character will be discarded from either end of this `str`.

Returns:
  a new String, stripped of the whitespace characters/bytes

### strip

public String strip(String stripChars)
Equivalent of Python `str.strip()`.

Parameters:
  `stripChars` - characters to strip from either end of this str/bytes, or null
Returns:
  a new String, stripped of the specified characters/bytes

### strip

public PyObject strip(PyObject stripChars)
Equivalent of Python `str.strip()`. Any byte/character matching one of those in `stripChars` will be discarded from either end of this `str`. If `stripChars == null`, whitespace will be stripped. If `stripChars` is a `PyUnicode`, the result will also be a `PyUnicode`.

Parameters:
  `stripChars` - characters to strip from either end of this str/bytes, or null
Returns:
  a new `PyString` (or `PyUnicode`), stripped of the specified characters/bytes

### lstrip

public String lstrip()
Equivalent of Python `str.lstrip()` with no argument, meaning strip whitespace. Any whitespace byte/character will be discarded from the left of this `str`.

Returns:
  a new String, stripped of the whitespace characters/bytes

### lstrip

public String lstrip(String stripChars)
Equivalent of Python `str.lstrip()`.

Parameters:
  `stripChars` - characters to strip from the left end of this str/bytes, or null
Returns:
  a new String, stripped of the specified characters/bytes

### lstrip

public PyObject lstrip(PyObject stripChars)
Equivalent of Python `str.lstrip()`. Any byte/character matching one of those in `stripChars` will be discarded from the left end of this `str`. If `stripChars == null`, whitespace will be stripped. If `stripChars` is a `PyUnicode`, the result will also be a `PyUnicode`.

Parameters:
  `stripChars` - characters to strip from the left end of this str/bytes, or null
Returns:
  a new `PyString` (or `PyUnicode`), stripped of the specified characters/bytes

### rstrip

public String rstrip()
Equivalent of Python `str.rstrip()` with no argument, meaning strip whitespace. Any whitespace byte/character will be discarded from the right end of this `str`.

Returns:
  a new String, stripped of the whitespace characters/bytes

### rstrip

public String rstrip(String stripChars)
Equivalent of Python `str.rstrip()`.

Parameters:
  `stripChars` - characters to strip from either end of this str/bytes, or null
Returns:
  a new String, stripped of the specified characters/bytes

### rstrip

public PyObject rstrip(PyObject stripChars)
Equivalent of Python `str.rstrip()`. Any byte/character matching one of those in `stripChars` will be discarded from the right end of this `str`. If `stripChars == null`, whitespace will be stripped. If `stripChars` is a `PyUnicode`, the result will also be a `PyUnicode`.

Parameters:
  `stripChars` - characters to strip from the right end of this str/bytes, or null
Returns:
  a new `PyString` (or `PyUnicode`), stripped of the specified characters/bytes

### split

public PyList split()
Equivalent to Python `str.split()`, splitting on runs of whitespace.

Returns:
  list(str) result

### split

public PyList split(String sep)
Equivalent to Python `str.split()`, splitting on a specified string.

Parameters:
  `sep` - string to use as separator (or `null` if to split on whitespace)
Returns:
  list(str) result

### split

public PyList split(String sep, int maxsplit)
Equivalent to Python `str.split()`, splitting on a specified string.

Parameters:
  `sep` - string to use as separator (or `null` if to split on whitespace)
  `maxsplit` - maximum number of splits to make (there may be `maxsplit+1` parts).
Returns:
  list(str) result

### split

public PyList split(PyObject sep)
Equivalent to Python `str.split()` returning a `PyList` of `PyString`s (or `PyUnicode`s). The `str` will be split at each occurrence of `sep`. If `sep == null`, whitespace will be used as the criterion. If `sep` has zero length, a Python `ValueError` is raised.

Parameters:
  `sep` - string to use as separator (or `null` if to split on whitespace)
Returns:
  list(str) result

### split

public PyList split(PyObject sep, int maxsplit)
As `split(PyObject)` but if `maxsplit` >=0 and there are more feasible splits than `maxsplit`, the last element of the list contains the rest of the string.

Parameters:
  `sep` - string to use as separator (or `null` if to split on whitespace)
  `maxsplit` - maximum number of splits to make (there may be `maxsplit+1` parts).
Returns:
  list(str) result

### rsplit

public PyList rsplit()
Equivalent to Python `str.rsplit()`, splitting on runs of whitespace.

Returns:
  list(str) result

### rsplit

public PyList rsplit(String sep)
Equivalent to Python `str.rsplit()`, splitting on a specified string.

Parameters:
  `sep` - string to use as separator (or `null` if to split on whitespace)
Returns:
  list(str) result

### rsplit

public PyList rsplit(String sep, int maxsplit)
Equivalent to Python `str.rsplit()`, splitting on a specified string.

Parameters:
  `sep` - string to use as separator (or `null` if to split on whitespace)
  `maxsplit` - maximum number of splits to make (there may be `maxsplit+1` parts).
Returns:
  list(str) result

### rsplit

public PyList rsplit(PyObject sep)
Equivalent to Python `str.rsplit()` returning a `PyList` of `PyString`s (or `PyUnicode`s). The `str` will be split at each occurrence of `sep`, working from the right. If `sep == null`, whitespace will be used as the criterion. If `sep` has zero length, a Python `ValueError` is raised.

Parameters:
  `sep` - string to use as separator (or `null` if to split on whitespace)
Returns:
  list(str) result

### rsplit

public PyList rsplit(PyObject sep, int maxsplit)
As `rsplit(PyObject)` but if `maxsplit` >=0 and there are more feasible splits than `maxsplit` the last element of the list contains the rest of the string.

Parameters:
  `sep` - string to use as separator (or `null` if to split on whitespace)
  `maxsplit` - maximum number of splits to make (there may be `maxsplit+1` parts).
Returns:
  list(str) result

### partition

public PyTuple partition(PyObject sepObj)
Equivalent to Python `str.partition()`, splits the `PyString` at the first occurrence of `sepObj` returning a `PyTuple` containing the part before the separator, the separator itself, and the part after the separator.

Parameters:
  `sepObj` - str, unicode or object implementing `BufferProtocol`
Returns:
  tuple of parts

### rpartition

public PyTuple rpartition(PyObject sepObj)
Equivalent to Python `str.rpartition()`, splits the `PyString` at the last occurrence of `sepObj` returning a `PyTuple` containing the part before the separator, the separator itself, and the part after the separator.

Parameters:
  `sepObj` - str, unicode or object implementing `BufferProtocol`
Returns:
  tuple of parts

### splitlines

public PyList splitlines()

### splitlines

public PyList splitlines(boolean keepends)

### index

public int index(PyObject sub)
Return the lowest index in the string where substring `sub` is found. Raises `ValueError` if the substring is not found.

Parameters:
  `sub` - substring to find.
Returns:
  index of `sub` in this object.
Throws:
  `PyException` - `ValueError` if not found.

### index

public int index(PyObject sub, PyObject start) throws PyException
Return the lowest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:]`. Raises `ValueError` if the substring is not found.

Parameters:
  `sub` - substring to find.
  `start` - start of slice.
Returns:
  index of `sub` in this object.
Throws:
  `PyException` - `ValueError` if not found.

### index

public int index(PyObject sub, PyObject start, PyObject end) throws PyException
Return the lowest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:end]`. Arguments `start` and `end` are interpreted as in slice notation, with null or `Py.None` representing "missing". Raises `ValueError` if the substring is not found.

Parameters:
  `sub` - substring to find.
  `start` - start of slice.
  `end` - end of slice.
Returns:
  index of `sub` in this object.
Throws:
  `PyException` - `ValueError` if not found.

### index

public int index(String sub)
Equivalent to `index(PyObject)` specialized to `String`.

### index

public int index(String sub, PyObject start)
Equivalent to `index(PyObject, PyObject)` specialized to `String`.

### index

public int index(String sub, PyObject start, PyObject end)
Equivalent to `index(PyObject, PyObject, PyObject)` specialized to `String` .

### rindex

public int rindex(PyObject sub)
Return the highest index in the string where substring `sub` is found. Raises `ValueError` if the substring is not found.

Parameters:
  `sub` - substring to find.
Returns:
  index of `sub` in this object.
Throws:
  `PyException` - `ValueError` if not found.

### rindex

public int rindex(PyObject sub, PyObject start) throws PyException
Return the highest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:]`. Raises `ValueError` if the substring is not found.

Parameters:
  `sub` - substring to find.
  `start` - start of slice.
Returns:
  index of `sub` in this object.
Throws:
  `PyException` - `ValueError` if not found.

### rindex

public int rindex(PyObject sub, PyObject start, PyObject end) throws PyException
Return the highest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:end]`. Arguments `start` and `end` are interpreted as in slice notation, with null or `Py.None` representing "missing". Raises `ValueError` if the substring is not found.

Parameters:
  `sub` - substring to find.
  `start` - start of slice.
  `end` - end of slice.
Returns:
  index of `sub` in this object.
Throws:
  `PyException` - `ValueError` if not found.

### rindex

public int rindex(String sub)
Equivalent to `rindex(PyObject)` specialized to `String`.

### rindex

public int rindex(String sub, PyObject start)
Equivalent to `rindex(PyObject, PyObject)` specialized to `String`.

### rindex

public int rindex(String sub, PyObject start, PyObject end)
Equivalent to `rindex(PyObject, PyObject, PyObject)` specialized to `String`.

### count

public int count(PyObject sub)
Return the number of non-overlapping occurrences of substring `sub`.

Parameters:
  `sub` - substring to find.
Returns:
  count of occurrences.

### count

public int count(PyObject sub, PyObject start)
Return the number of non-overlapping occurrences of substring `sub` in the range `[start:]`.

Parameters:
  `sub` - substring to find.
  `start` - start of slice.
Returns:
  count of occurrences.

### count

public int count(PyObject sub, PyObject start, PyObject end)
Return the number of non-overlapping occurrences of substring `sub` in the range `[start:end]`. Optional arguments `start` and `end` are interpreted as in slice notation.

Parameters:
  `sub` - substring to find.
  `start` - start of slice.
  `end` - end of slice.
Returns:
  count of occurrences.

### count

public int count(String sub)
Equivalent to `count(PyObject)` specialized to `String`.

### count

public int count(String sub, PyObject start)
Equivalent to `count(PyObject, PyObject)` specialized to `String`.

### count

public int count(String sub, PyObject start, PyObject end)
Equivalent to `count(PyObject, PyObject, PyObject)` specialized to `String` .

### find

public int find(PyObject sub)
Return the lowest index in the string where substring `sub` is found.

Parameters:
  `sub` - substring to find.
Returns:
  index of `sub` in this object or -1 if not found.

### find

public int find(PyObject sub, PyObject start)
Return the lowest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:]`.

Parameters:
  `sub` - substring to find.
  `start` - start of slice.
Returns:
  index of `sub` in this object or -1 if not found.

### find

public int find(PyObject sub, PyObject start, PyObject end)
Return the lowest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:end]`. Arguments `start` and `end` are interpreted as in slice notation, with null or `Py.None` representing "missing".

Parameters:
  `sub` - substring to find.
  `start` - start of slice.
  `end` - end of slice.
Returns:
  index of `sub` in this object or -1 if not found.

### find

public int find(String sub)
Equivalent to `find(PyObject)` specialized to `String`.

### find

public int find(String sub, PyObject start)
Equivalent to `find(PyObject, PyObject)` specialized to `String`.

### find

public int find(String sub, PyObject start, PyObject end)
Equivalent to `find(PyObject, PyObject, PyObject)` specialized to `String`.

### rfind

public int rfind(PyObject sub)
Return the highest index in the string where substring `sub` is found.

Parameters:
  `sub` - substring to find.
Returns:
  index of `sub` in this object or -1 if not found.

### rfind

public int rfind(PyObject sub, PyObject start)
Return the highest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:]`.

Parameters:
  `sub` - substring to find.
  `start` - start of slice.
Returns:
  index of `sub` in this object or -1 if not found.

### rfind

public int rfind(PyObject sub, PyObject start, PyObject end)
Return the highest index in the string where substring `sub` is found, such that `sub` is contained in the slice `s[start:end]`. Arguments `start` and `end` are interpreted as in slice notation, with null or `Py.None` representing "missing".

Parameters:
  `sub` - substring to find.
  `start` - start of slice.
  `end` - end of slice.
Returns:
  index of `sub` in this object or -1 if not found.

### rfind

public int rfind(String sub)
Equivalent to `find(PyObject)` specialized to `String`.

### rfind

public int rfind(String sub, PyObject start)
Equivalent to `find(PyObject, PyObject)` specialized to `String`.

### rfind

public int rfind(String sub, PyObject start, PyObject end)
Equivalent to `find(PyObject, PyObject, PyObject)` specialized to `String`.

### atof

public double atof()
Convert this PyString to a floating-point value according to Python rules.

Returns:
  the value

### atoi

public int atoi()

### atoi

public int atoi(int base)

### atol

public PyLong atol()

### atol

public PyLong atol(int base)

### ljust

public String ljust(int width)

### ljust

public String ljust(int width, String padding)

### rjust

public String rjust(int width)

### center

public String center(int width)

### zfill

public String zfill(int width)

### expandtabs

public String expandtabs()

### expandtabs

public String expandtabs(int tabsize)

### capitalize

public String capitalize()

### replace

public PyString replace(PyObject oldPiece, PyObject newPiece)
Equivalent to Python str.replace(old, new), returning a copy of the string with all occurrences of substring old replaced by new. If either argument is a `PyUnicode` (or this object is), the result will be a `PyUnicode`.

Parameters:
  `oldPiece` - to replace where found.
  `newPiece` - replacement text.
Returns:
  PyString (or PyUnicode if any string is one), this string after replacements.

### replace

public PyString replace(PyObject oldPiece, PyObject newPiece, int count)
Equivalent to Python str.replace(old, new[, count]), returning a copy of the string with all occurrences of substring old replaced by new. If argument `count` is nonnegative, only the first `count` occurrences are replaced. If either argument is a `PyUnicode` (or this object is), the result will be a `PyUnicode`.

Parameters:
  `oldPiece` - to replace where found.
  `newPiece` - replacement text.
  `count` - maximum number of replacements to make, or -1 meaning all of them.
Returns:
  PyString (or PyUnicode if any string is one), this string after replacements.

### join

public PyString join(PyObject seq)

### startswith

public boolean startswith(PyObject prefix)
Equivalent to the Python `str.startswith` method testing whether a string starts with a specified prefix. `prefix` can also be a tuple of prefixes to look for.

Parameters:
  `prefix` - string to check for (or a `PyTuple` of them).
Returns:
  `true` if this string slice starts with a specified prefix, otherwise `false`.

### startswith

public boolean startswith(PyObject prefix, PyObject start)
Equivalent to the Python `str.startswith` method, testing whether a string starts with a specified prefix, where a sub-range is specified by `[start:]`. `start` is interpreted as in slice notation, with null or `Py.None` representing "missing". `prefix` can also be a tuple of prefixes to look for.

Parameters:
  `prefix` - string to check for (or a `PyTuple` of them).
  `start` - start of slice.
Returns:
  `true` if this string slice starts with a specified prefix, otherwise `false`.

### startswith

public boolean startswith(PyObject prefix, PyObject start, PyObject end)
Equivalent to the Python `str.startswith` method, testing whether a string starts with a specified prefix, where a sub-range is specified by `[start:end]`. Arguments `start` and `end` are interpreted as in slice notation, with null or `Py.None` representing "missing". `prefix` can also be a tuple of prefixes to look for.

Parameters:
  `prefix` - string to check for (or a `PyTuple` of them).
  `start` - start of slice.
  `end` - end of slice.
Returns:
  `true` if this string slice starts with a specified prefix, otherwise `false`.

### endswith

public boolean endswith(PyObject suffix)
Equivalent to the Python `str.endswith` method, testing whether a string ends with a specified suffix. `suffix` can also be a tuple of suffixes to look for.

Parameters:
  `suffix` - string to check for (or a `PyTuple` of them).
Returns:
  `true` if this string slice ends with a specified suffix, otherwise `false`.

### endswith

public boolean endswith(PyObject suffix, PyObject start)
Equivalent to the Python `str.endswith` method, testing whether a string ends with a specified suffix, where a sub-range is specified by `[start:]`. `start` is interpreted as in slice notation, with null or `Py.None` representing "missing". `suffix` can also be a tuple of suffixes to look for.

Parameters:
  `suffix` - string to check for (or a `PyTuple` of them).
  `start` - start of slice.
Returns:
  `true` if this string slice ends with a specified suffix, otherwise `false`.

### endswith

public boolean endswith(PyObject suffix, PyObject start, PyObject end)
Equivalent to the Python `str.endswith` method, testing whether a string ends with a specified suffix, where a sub-range is specified by `[start:end]`. Arguments `start` and `end` are interpreted as in slice notation, with null or `Py.None` representing "missing". `suffix` can also be a tuple of suffixes to look for.

Parameters:
  `suffix` - string to check for (or a `PyTuple` of them).
  `start` - start of slice.
  `end` - end of slice.
Returns:
  `true` if this string slice ends with a specified suffix, otherwise `false`.

### translate

public String translate(PyObject table)
Equivalent to Python `str.translate` returning a copy of this string where the characters have been mapped through the translation `table`. `table` must be equivalent to a string of length 256 (if it is not `null`).

Parameters:
  `table` - of character (byte) translations (or `null`)
Returns:
  transformed byte string

### translate

public String translate(PyObject table, PyObject deletechars)
Equivalent to Python `str.translate` returning a copy of this string where all characters (bytes) occurring in the argument `deletechars` are removed (if it is not `null`), and the remaining characters have been mapped through the translation `table`. `table` must be equivalent to a string of length 256 (if it is not `null`).

Parameters:
  `table` - of character (byte) translations (or `null`)
  `deletechars` - set of characters to remove (or `null`)
Returns:
  transformed byte string

### translate

public String translate(String table)
Equivalent to `translate(PyObject)` specialized to `String`.

### translate

public String translate(String table, String deletechars)
Equivalent to `translate(PyObject, PyObject)` specialized to `String`.

### islower

public boolean islower()

### isupper

public boolean isupper()

### isalpha

public boolean isalpha()

### isalnum

public boolean isalnum()

### isdecimal

public boolean isdecimal()

### isdigit

public boolean isdigit()

### isnumeric

public boolean isnumeric()

### istitle

public boolean istitle()

### isspace

public boolean isspace()

### isunicode

public boolean isunicode()

### encode

public String encode()

### encode

public String encode(String encoding)

### encode

public String encode(String encoding, String errors)

### decode

public PyObject decode()

### decode

public PyObject decode(String encoding)

### decode

public PyObject decode(String encoding, String errors)

### __format__

public PyObject __format__(PyObject formatSpec)

Overrides:
  `__format__` in class `PyObject`

### asString

public String asString(int index) throws PyObject.ConversionException

Overrides:
  `asString` in class `PyObject`
Throws:
  `PyObject.ConversionException`

### asString

public String asString()

Overrides:
  `asString` in class `PyObject`

### asInt

public int asInt()
Description copied from class: `PyObject`
Convert this object into an int. Throws a PyException on failure.

Overrides:
  `asInt` in class `PyObject`
Returns:
  an int value

### asLong

public long asLong()
Description copied from class: `PyObject`
Convert this object into a long. Throws a PyException on failure.

Overrides:
  `asLong` in class `PyObject`
Returns:
  an long value

### asDouble

public double asDouble()
Description copied from class: `PyObject`
Convert this object into a double. Throws a PyException on failure.

Overrides:
  `asDouble` in class `PyObject`
Returns:
  a double value

### asName

public String asName(int index) throws PyObject.ConversionException

Overrides:
  `asName` in class `PyObject`
Throws:
  `PyObject.ConversionException`

### charAt

public char charAt(int index)

Specified by:
  `charAt` in interface `CharSequence`
Overrides:
  `charAt` in class `PyBaseString`

### length

public int length()

Specified by:
  `length` in interface `CharSequence`
Overrides:
  `length` in class `PyBaseString`

### subSequence

public CharSequence subSequence(int start, int end)

Specified by:
  `subSequence` in interface `CharSequence`
Overrides:
  `subSequence` in class `PyBaseString`