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
A builtin python string.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.python.core.PyObject
PyObject.ConversionException
-
Field Summary
Fields inherited from class org.python.core.PyObject
gcMonitorGlobal
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionEquivalent to the standard Python __add__ method.int
Equivalent to the standard Python __cmp__ method.Equivalent to the standard Python __complex__ method.boolean
Equivalent to the standard Python __contains__ method.Equivalent to the standard Python __eq__ method.Equivalent to the standard Python __float__ method.__format__
(PyObject formatSpec) Equivalent to the standard Python __ge__ method.Equivalent to the standard Python __gt__ method.__int__()
Equivalent to the standard Python __int__ method.Equivalent to the standard Python __invert__ method.Equivalent to the standard Python __le__ method.int
__len__()
Equivalent to the standard Python __len__ method.__long__()
Equivalent to the standard Python __long__ method.Equivalent to the standard Python __lt__ method.Equivalent to the standard Python __mod__ methodEquivalent to the standard Python __mul__ method.Equivalent to the standard Python __ne__ method.__neg__()
Equivalent to the standard Python __neg__ method.__pos__()
Equivalent to the standard Python __pos__ method.__repr__()
Equivalent to the standard Python__repr__
method.Equivalent to the standard Python __rmul__ method.__str__()
Equivalent to the standard Python __str__ method.__tojava__
(Class<?> c) Equivalent to the Jython __tojava__ method.double
asDouble()
Convert this object into a double.int
asInt()
Convert this object into an int.long
asLong()
Convert this object into a long.asName
(int index) asString()
asString
(int index) double
atof()
Convert this PyString to a floating-point value according to Python rules.int
atoi()
int
atoi
(int base) atol()
atol
(int base) center
(int width) char
charAt
(int index) int
Equivalent tocount(PyObject)
specialized toString
.int
Equivalent tocount(PyObject, PyObject)
specialized toString
.int
Equivalent tocount(PyObject, PyObject, PyObject)
specialized toString
.int
Return the number of non-overlapping occurrences of substringsub
.int
Return the number of non-overlapping occurrences of substringsub
in the range[start:]
.int
Return the number of non-overlapping occurrences of substringsub
in the range[start:end]
.createInstance
(String str) Create an instance of the same type as this object, from the Java String given as argument.decode()
static String
decode_UnicodeEscape
(String str, int start, int end, String errors, boolean unicode) encode()
static String
encode_UnicodeEscape
(String str, boolean use_quotes) boolean
Equivalent to the Pythonstr.endswith
method, testing whether a string ends with a specified suffix.boolean
Equivalent to the Pythonstr.endswith
method, testing whether a string ends with a specified suffix, where a sub-range is specified by[start:]
.boolean
Equivalent to the Pythonstr.endswith
method, testing whether a string ends with a specified suffix, where a sub-range is specified by[start:end]
.expandtabs
(int tabsize) int
Equivalent tofind(PyObject)
specialized toString
.int
Equivalent tofind(PyObject, PyObject)
specialized toString
.int
Equivalent tofind(PyObject, PyObject, PyObject)
specialized toString
.int
Return the lowest index in the string where substringsub
is found.int
Return the lowest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:]
.int
Return the lowest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:end]
.static PyString
fromInterned
(String interned) Creates aPyString
from an already internedString
representing bytes.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) int
hashCode()
int
Equivalent toindex(PyObject)
specialized toString
.int
Equivalent toindex(PyObject, PyObject)
specialized toString
.int
Equivalent toindex(PyObject, PyObject, PyObject)
specialized toString
.int
Return the lowest index in the string where substringsub
is found.int
Return the lowest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:]
.int
Return the lowest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:end]
.boolean
isalnum()
boolean
isalpha()
boolean
Determine whether the string consists entirely of basic-plane characters.boolean
boolean
isdigit()
boolean
islower()
boolean
boolean
isspace()
boolean
istitle()
boolean
boolean
isupper()
int
length()
ljust
(int width) lower()
lstrip()
Equivalent of Pythonstr.lstrip()
with no argument, meaning strip whitespace.Equivalent of Pythonstr.lstrip()
.Equivalent of Pythonstr.lstrip()
.Equivalent to Pythonstr.partition()
, splits thePyString
at the first occurrence ofsepObj
returning aPyTuple
containing the part before the separator, the separator itself, and the part after the separator.Equivalent to Python str.replace(old, new), returning a copy of the string with all occurrences of substring old replaced by new.Equivalent to Python str.replace(old, new[, count]), returning a copy of the string with all occurrences of substring old replaced by new.int
Equivalent tofind(PyObject)
specialized toString
.int
Equivalent tofind(PyObject, PyObject)
specialized toString
.int
Equivalent tofind(PyObject, PyObject, PyObject)
specialized toString
.int
Return the highest index in the string where substringsub
is found.int
Return the highest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:]
.int
Return the highest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:end]
.int
Equivalent torindex(PyObject)
specialized toString
.int
Equivalent torindex(PyObject, PyObject)
specialized toString
.int
Equivalent torindex(PyObject, PyObject, PyObject)
specialized toString
.int
Return the highest index in the string where substringsub
is found.int
Return the highest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:]
.int
Return the highest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:end]
.rjust
(int width) rpartition
(PyObject sepObj) Equivalent to Pythonstr.rpartition()
, splits thePyString
at the last occurrence ofsepObj
returning aPyTuple
containing the part before the separator, the separator itself, and the part after the separator.rsplit()
Equivalent to Pythonstr.rsplit()
, splitting on runs of whitespace.Equivalent to Pythonstr.rsplit()
, splitting on a specified string.Equivalent to Pythonstr.rsplit()
, splitting on a specified string.Asrsplit(PyObject)
but ifmaxsplit
>=0 and there are more feasible splits thanmaxsplit
the last element of the list contains the rest of the string.rstrip()
Equivalent of Pythonstr.rstrip()
with no argument, meaning strip whitespace.Equivalent of Pythonstr.rstrip()
.Equivalent of Pythonstr.rstrip()
.split()
Equivalent to Pythonstr.split()
, splitting on runs of whitespace.Equivalent to Pythonstr.split()
, splitting on a specified string.Equivalent to Pythonstr.split()
, splitting on a specified string.Assplit(PyObject)
but ifmaxsplit
>=0 and there are more feasible splits thanmaxsplit
, the last element of the list contains the rest of the string.splitlines
(boolean keepends) boolean
startswith
(PyObject prefix) Equivalent to the Pythonstr.startswith
method testing whether a string starts with a specified prefix.boolean
startswith
(PyObject prefix, PyObject start) Equivalent to the Pythonstr.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 Pythonstr.startswith
method, testing whether a string starts with a specified prefix, where a sub-range is specified by[start:end]
.str___mod__
(PyObject other) strip()
Equivalent of Pythonstr.strip()
with no argument, meaning strip whitespace.Equivalent of Pythonstr.strip()
.Equivalent of Pythonstr.strip()
.subSequence
(int start, int end) substring
(int start, int end) Return a substring of this object as a Java String.swapcase()
title()
byte[]
toBytes()
int[]
toString()
Equivalent totranslate(PyObject)
specialized toString
.Equivalent totranslate(PyObject, PyObject)
specialized toString
.Equivalent to Pythonstr.translate
returning a copy of this string where the characters have been mapped through the translationtable
.Equivalent to Pythonstr.translate
returning a copy of this string where all characters (bytes) occurring in the argumentdeletechars
are removed (if it is notnull
), and the remaining characters have been mapped through the translationtable
.upper()
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 interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Field Details
-
TYPE
-
-
Constructor Details
-
PyString
public PyString() -
PyString
Fundamental constructor forPyString
objects when the client provides a JavaString
, necessitating that we range check the characters.- Parameters:
subType
- the actual type being constructedstring
- a Java String to be wrapped
-
PyString
-
PyString
public PyString(char c)
-
-
Method Details
-
getString
-
fromInterned
Creates aPyString
from an already internedString
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 aPyString
, of course, it is alwaystrue
, but this is useful in cases where either aPyString
or aPyUnicode
is acceptable.- Returns:
- true
-
toCodePoints
public int[] toCodePoints() -
getBuffer
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 theflags
argument (see the constants in interfacePyBUF
for an explanation). The method may return the same PyBuffer object to more than one consumer.- Specified by:
getBuffer
in interfaceBufferProtocol
- Parameters:
flags
- consumer requirements- Returns:
- the requested buffer
-
substring
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__
Description copied from class:PyObject
Equivalent to the standard Python __str__ method. The default implementation (inPyObject
) callsPyObject.__repr__()
, making it unnecessary to override__str__
in sub-classes ofPyObject
where both forms are the same. A common choice is to provide the same implementation to__str__
andtoString
, for consistency in the printed form of objects between Python and Java. -
__unicode__
- Overrides:
__unicode__
in classPyObject
-
__len__
public int __len__()Description copied from class:PyObject
Equivalent to the standard Python __len__ method. Part of the mapping discipline. -
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classPyObject
-
internedString
-
__repr__
Description copied from class:PyObject
Equivalent to the standard Python__repr__
method. Each sub-class ofPyObject
is likely to re-define this method to provide for its own reproduction. -
encode_UnicodeEscape
-
decode_UnicodeEscape
-
__cmp__
Description copied from class:PyObject
Equivalent to the standard Python __cmp__ method. -
__eq__
Description copied from class:PyObject
Equivalent to the standard Python __eq__ method.- Overrides:
__eq__
in classPySequence
- Parameters:
other
- the object to compare this with.- Returns:
- the result of the comparison.
-
__ne__
Description copied from class:PyObject
Equivalent to the standard Python __ne__ method.- Overrides:
__ne__
in classPySequence
- Parameters:
other
- the object to compare this with.- Returns:
- the result of the comparison.
-
__lt__
Description copied from class:PyObject
Equivalent to the standard Python __lt__ method.- Overrides:
__lt__
in classPySequence
- Parameters:
other
- the object to compare this with.- Returns:
- the result of the comparison.
-
__le__
Description copied from class:PyObject
Equivalent to the standard Python __le__ method.- Overrides:
__le__
in classPySequence
- Parameters:
other
- the object to compare this with.- Returns:
- the result of the comparison.
-
__gt__
Description copied from class:PyObject
Equivalent to the standard Python __gt__ method.- Overrides:
__gt__
in classPySequence
- Parameters:
other
- the object to compare this with.- Returns:
- the result of the comparison.
-
__ge__
Description copied from class:PyObject
Equivalent to the standard Python __ge__ method.- Overrides:
__ge__
in classPySequence
- Parameters:
other
- the object to compare this with.- Returns:
- the result of the comparison.
-
hashCode
public int hashCode() -
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__
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 objectPy.NoConversion
if thisPyObject
can not be converted to the desired Java class.- Overrides:
__tojava__
in classPySequence
- Parameters:
c
- the Class to convert thisPyObject
to.
-
getInt
public int getInt(int i) -
createInstance
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__
Description copied from class:PyObject
Equivalent to the standard Python __contains__ method.- Overrides:
__contains__
in classPyObject
- Parameters:
o
- the element to search for in this container.- Returns:
- the result of the search.
-
__mul__
Description copied from class:PyObject
Equivalent to the standard Python __mul__ method. -
__rmul__
Description copied from class:PyObject
Equivalent to the standard Python __rmul__ method. -
__add__
-
__getnewargs__
- Overrides:
__getnewargs__
in classPyObject
-
__mod__
Description copied from class:PyObject
Equivalent to the standard Python __mod__ method -
str___mod__
-
__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. -
__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. -
__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. -
__pos__
Description copied from class:PyObject
Equivalent to the standard Python __pos__ method. -
__neg__
Description copied from class:PyObject
Equivalent to the standard Python __neg__ method. -
__invert__
Description copied from class:PyObject
Equivalent to the standard Python __invert__ method.- Overrides:
__invert__
in classPyObject
- Returns:
- ~this.
-
__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 classPyObject
- Returns:
- a complex number corresponding to the value of this object.
-
lower
-
upper
-
title
-
swapcase
-
strip
Equivalent of Pythonstr.strip()
with no argument, meaning strip whitespace. Any whitespace byte/character will be discarded from either end of thisstr
.- Returns:
- a new String, stripped of the whitespace characters/bytes
-
strip
Equivalent of Pythonstr.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
Equivalent of Pythonstr.strip()
. Any byte/character matching one of those instripChars
will be discarded from either end of thisstr
. IfstripChars == null
, whitespace will be stripped. IfstripChars
is aPyUnicode
, the result will also be aPyUnicode
.- Parameters:
stripChars
- characters to strip from either end of this str/bytes, or null- Returns:
- a new
PyString
(orPyUnicode
), stripped of the specified characters/bytes
-
lstrip
Equivalent of Pythonstr.lstrip()
with no argument, meaning strip whitespace. Any whitespace byte/character will be discarded from the left of thisstr
.- Returns:
- a new String, stripped of the whitespace characters/bytes
-
lstrip
Equivalent of Pythonstr.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
Equivalent of Pythonstr.lstrip()
. Any byte/character matching one of those instripChars
will be discarded from the left end of thisstr
. IfstripChars == null
, whitespace will be stripped. IfstripChars
is aPyUnicode
, the result will also be aPyUnicode
.- Parameters:
stripChars
- characters to strip from the left end of this str/bytes, or null- Returns:
- a new
PyString
(orPyUnicode
), stripped of the specified characters/bytes
-
rstrip
Equivalent of Pythonstr.rstrip()
with no argument, meaning strip whitespace. Any whitespace byte/character will be discarded from the right end of thisstr
.- Returns:
- a new String, stripped of the whitespace characters/bytes
-
rstrip
Equivalent of Pythonstr.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
Equivalent of Pythonstr.rstrip()
. Any byte/character matching one of those instripChars
will be discarded from the right end of thisstr
. IfstripChars == null
, whitespace will be stripped. IfstripChars
is aPyUnicode
, the result will also be aPyUnicode
.- Parameters:
stripChars
- characters to strip from the right end of this str/bytes, or null- Returns:
- a new
PyString
(orPyUnicode
), stripped of the specified characters/bytes
-
split
Equivalent to Pythonstr.split()
, splitting on runs of whitespace.- Returns:
- list(str) result
-
split
Equivalent to Pythonstr.split()
, splitting on a specified string.- Parameters:
sep
- string to use as separator (ornull
if to split on whitespace)- Returns:
- list(str) result
-
split
Equivalent to Pythonstr.split()
, splitting on a specified string.- Parameters:
sep
- string to use as separator (ornull
if to split on whitespace)maxsplit
- maximum number of splits to make (there may bemaxsplit+1
parts).- Returns:
- list(str) result
-
split
Equivalent to Pythonstr.split()
returning aPyList
ofPyString
s (orPyUnicode
s). Thestr
will be split at each occurrence ofsep
. Ifsep == null
, whitespace will be used as the criterion. Ifsep
has zero length, a PythonValueError
is raised.- Parameters:
sep
- string to use as separator (ornull
if to split on whitespace)- Returns:
- list(str) result
-
split
Assplit(PyObject)
but ifmaxsplit
>=0 and there are more feasible splits thanmaxsplit
, the last element of the list contains the rest of the string.- Parameters:
sep
- string to use as separator (ornull
if to split on whitespace)maxsplit
- maximum number of splits to make (there may bemaxsplit+1
parts).- Returns:
- list(str) result
-
rsplit
Equivalent to Pythonstr.rsplit()
, splitting on runs of whitespace.- Returns:
- list(str) result
-
rsplit
Equivalent to Pythonstr.rsplit()
, splitting on a specified string.- Parameters:
sep
- string to use as separator (ornull
if to split on whitespace)- Returns:
- list(str) result
-
rsplit
Equivalent to Pythonstr.rsplit()
, splitting on a specified string.- Parameters:
sep
- string to use as separator (ornull
if to split on whitespace)maxsplit
- maximum number of splits to make (there may bemaxsplit+1
parts).- Returns:
- list(str) result
-
rsplit
Equivalent to Pythonstr.rsplit()
returning aPyList
ofPyString
s (orPyUnicode
s). Thestr
will be split at each occurrence ofsep
, working from the right. Ifsep == null
, whitespace will be used as the criterion. Ifsep
has zero length, a PythonValueError
is raised.- Parameters:
sep
- string to use as separator (ornull
if to split on whitespace)- Returns:
- list(str) result
-
rsplit
Asrsplit(PyObject)
but ifmaxsplit
>=0 and there are more feasible splits thanmaxsplit
the last element of the list contains the rest of the string.- Parameters:
sep
- string to use as separator (ornull
if to split on whitespace)maxsplit
- maximum number of splits to make (there may bemaxsplit+1
parts).- Returns:
- list(str) result
-
partition
Equivalent to Pythonstr.partition()
, splits thePyString
at the first occurrence ofsepObj
returning aPyTuple
containing the part before the separator, the separator itself, and the part after the separator.- Parameters:
sepObj
- str, unicode or object implementingBufferProtocol
- Returns:
- tuple of parts
-
rpartition
Equivalent to Pythonstr.rpartition()
, splits thePyString
at the last occurrence ofsepObj
returning aPyTuple
containing the part before the separator, the separator itself, and the part after the separator.- Parameters:
sepObj
- str, unicode or object implementingBufferProtocol
- Returns:
- tuple of parts
-
splitlines
-
splitlines
-
index
Return the lowest index in the string where substringsub
is found. RaisesValueError
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
Return the lowest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:]
. RaisesValueError
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
Return the lowest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:end]
. Argumentsstart
andend
are interpreted as in slice notation, with null orPy.None
representing "missing". RaisesValueError
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
Equivalent toindex(PyObject)
specialized toString
. -
index
Equivalent toindex(PyObject, PyObject)
specialized toString
. -
index
Equivalent toindex(PyObject, PyObject, PyObject)
specialized toString
. -
rindex
Return the highest index in the string where substringsub
is found. RaisesValueError
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
Return the highest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:]
. RaisesValueError
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
Return the highest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:end]
. Argumentsstart
andend
are interpreted as in slice notation, with null orPy.None
representing "missing". RaisesValueError
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
Equivalent torindex(PyObject)
specialized toString
. -
rindex
Equivalent torindex(PyObject, PyObject)
specialized toString
. -
rindex
Equivalent torindex(PyObject, PyObject, PyObject)
specialized toString
. -
count
Return the number of non-overlapping occurrences of substringsub
.- Parameters:
sub
- substring to find.- Returns:
- count of occurrences.
-
count
Return the number of non-overlapping occurrences of substringsub
in the range[start:]
.- Parameters:
sub
- substring to find.start
- start of slice.- Returns:
- count of occurrences.
-
count
Return the number of non-overlapping occurrences of substringsub
in the range[start:end]
. Optional argumentsstart
andend
are interpreted as in slice notation.- Parameters:
sub
- substring to find.start
- start of slice.end
- end of slice.- Returns:
- count of occurrences.
-
count
Equivalent tocount(PyObject)
specialized toString
. -
count
Equivalent tocount(PyObject, PyObject)
specialized toString
. -
count
Equivalent tocount(PyObject, PyObject, PyObject)
specialized toString
. -
find
Return the lowest index in the string where substringsub
is found.- Parameters:
sub
- substring to find.- Returns:
- index of
sub
in this object or -1 if not found.
-
find
Return the lowest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:]
.- Parameters:
sub
- substring to find.start
- start of slice.- Returns:
- index of
sub
in this object or -1 if not found.
-
find
Return the lowest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:end]
. Argumentsstart
andend
are interpreted as in slice notation, with null orPy.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
Equivalent tofind(PyObject)
specialized toString
. -
find
Equivalent tofind(PyObject, PyObject)
specialized toString
. -
find
Equivalent tofind(PyObject, PyObject, PyObject)
specialized toString
. -
rfind
Return the highest index in the string where substringsub
is found.- Parameters:
sub
- substring to find.- Returns:
- index of
sub
in this object or -1 if not found.
-
rfind
Return the highest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:]
.- Parameters:
sub
- substring to find.start
- start of slice.- Returns:
- index of
sub
in this object or -1 if not found.
-
rfind
Return the highest index in the string where substringsub
is found, such thatsub
is contained in the slices[start:end]
. Argumentsstart
andend
are interpreted as in slice notation, with null orPy.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
Equivalent tofind(PyObject)
specialized toString
. -
rfind
Equivalent tofind(PyObject, PyObject)
specialized toString
. -
rfind
Equivalent tofind(PyObject, PyObject, PyObject)
specialized toString
. -
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
-
atol
-
ljust
-
ljust
-
rjust
-
center
-
zfill
-
expandtabs
-
expandtabs
-
capitalize
-
replace
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 aPyUnicode
(or this object is), the result will be aPyUnicode
.- Parameters:
oldPiece
- to replace where found.newPiece
- replacement text.- Returns:
- PyString (or PyUnicode if any string is one), this string after replacements.
-
replace
Equivalent to Python str.replace(old, new[, count]), returning a copy of the string with all occurrences of substring old replaced by new. If argumentcount
is nonnegative, only the firstcount
occurrences are replaced. If either argument is aPyUnicode
(or this object is), the result will be aPyUnicode
.- 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
-
startswith
Equivalent to the Pythonstr.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 aPyTuple
of them).- Returns:
true
if this string slice starts with a specified prefix, otherwisefalse
.
-
startswith
Equivalent to the Pythonstr.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 orPy.None
representing "missing".prefix
can also be a tuple of prefixes to look for.- Parameters:
prefix
- string to check for (or aPyTuple
of them).start
- start of slice.- Returns:
true
if this string slice starts with a specified prefix, otherwisefalse
.
-
startswith
Equivalent to the Pythonstr.startswith
method, testing whether a string starts with a specified prefix, where a sub-range is specified by[start:end]
. Argumentsstart
andend
are interpreted as in slice notation, with null orPy.None
representing "missing".prefix
can also be a tuple of prefixes to look for.- Parameters:
prefix
- string to check for (or aPyTuple
of them).start
- start of slice.end
- end of slice.- Returns:
true
if this string slice starts with a specified prefix, otherwisefalse
.
-
endswith
Equivalent to the Pythonstr.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 aPyTuple
of them).- Returns:
true
if this string slice ends with a specified suffix, otherwisefalse
.
-
endswith
Equivalent to the Pythonstr.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 orPy.None
representing "missing".suffix
can also be a tuple of suffixes to look for.- Parameters:
suffix
- string to check for (or aPyTuple
of them).start
- start of slice.- Returns:
true
if this string slice ends with a specified suffix, otherwisefalse
.
-
endswith
Equivalent to the Pythonstr.endswith
method, testing whether a string ends with a specified suffix, where a sub-range is specified by[start:end]
. Argumentsstart
andend
are interpreted as in slice notation, with null orPy.None
representing "missing".suffix
can also be a tuple of suffixes to look for.- Parameters:
suffix
- string to check for (or aPyTuple
of them).start
- start of slice.end
- end of slice.- Returns:
true
if this string slice ends with a specified suffix, otherwisefalse
.
-
translate
Equivalent to Pythonstr.translate
returning a copy of this string where the characters have been mapped through the translationtable
.table
must be equivalent to a string of length 256 (if it is notnull
).- Parameters:
table
- of character (byte) translations (ornull
)- Returns:
- transformed byte string
-
translate
Equivalent to Pythonstr.translate
returning a copy of this string where all characters (bytes) occurring in the argumentdeletechars
are removed (if it is notnull
), and the remaining characters have been mapped through the translationtable
.table
must be equivalent to a string of length 256 (if it is notnull
).- Parameters:
table
- of character (byte) translations (ornull
)deletechars
- set of characters to remove (ornull
)- Returns:
- transformed byte string
-
translate
Equivalent totranslate(PyObject)
specialized toString
. -
translate
Equivalent totranslate(PyObject, PyObject)
specialized toString
. -
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
-
encode
-
encode
-
decode
-
decode
-
decode
-
__format__
- Overrides:
__format__
in classPyObject
-
asString
- Overrides:
asString
in classPyObject
- Throws:
PyObject.ConversionException
-
asString
-
asInt
public int asInt()Description copied from class:PyObject
Convert this object into an int. Throws a PyException on failure. -
asLong
public long asLong()Description copied from class:PyObject
Convert this object into a long. Throws a PyException on failure. -
asDouble
public double asDouble()Description copied from class:PyObject
Convert this object into a double. Throws a PyException on failure. -
asName
- Overrides:
asName
in classPyObject
- Throws:
PyObject.ConversionException
-
charAt
public char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
- Overrides:
charAt
in classPyBaseString
-
length
public int length()- Specified by:
length
in interfaceCharSequence
- Overrides:
length
in classPyBaseString
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
- Overrides:
subSequence
in classPyBaseString
-