Top Description Fields Constructors Methods
org.python.core

public Class PyString

Additional top-level class in compilation unit: StringFormatter.

extends PyBaseString
implements BufferProtocol
Class Inheritance
All Implemented Interfaces
org.python.core.BufferProtocol
Known Direct Subclasses
org.python.core.PyStringDerived, org.python.core.PyUnicode, org.python.core.SyspathArchive, org.python.core.PyShadowString
Annotations
@Untraversable
@ExposedType
name:str
base:PyBaseString
doc:str(object) -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.
Imports
java.lang.ref.Reference, .SoftReference, java.math.BigInteger, java.util.ArrayList, .Arrays, .Collection, .List, java.util.regex.Matcher, .Pattern, org.python.core.buffer.BaseBuffer, .SimpleStringBuffer, org.python.core.stringlib.FieldNameIterator, .FloatFormatter, .IntegerFormatter, .InternalFormat, .InternalFormat.Formatter, .InternalFormat.Spec, .MarkupIterator, .TextFormatter, org.python.core.util.StringUtil, org.python.expose.ExposedMethod, .ExposedNew, .ExposedType, .MethodType

A builtin python string.

Field Summary

Modifier and TypeField and Description
private static Pattern
private Reference<BaseBuffer>
export

Supports the buffer API, see getBuffer(int).

private static Pattern
floatPattern

Access only through getFloatPattern().

private static char[]
protected transient boolean
private static ucnhashAPI
protected String
private static final int
public static final PyType
private static final String
UF_RE

Regular expression for an unsigned Python float, accepting also any sequence of the letters that belong to "NaN" or "Infinity" in whatever case.

Constructor Summary

AccessConstructor and Description
public
protected
PyString(PyType subType, String string, boolean isBytes)

public
PyString(PyType
the actual type being constructed
subType
,
String
a Java String to be wrapped
string
)

Fundamental constructor for PyString objects when the client provides a Java String, necessitating that we range check the characters.

public
PyString(String string)

public
PyString(char c)

pack-priv
pack-priv
pack-priv
PyString(String
a Java String to be wrapped (not null)
string
,
boolean
true if the client guarantees we are dealing with bytes
isBytes
)

Local-use constructor in which the client is allowed to guarantee that the String argument contains only characters in the byte range.

Method Summary

Modifier and TypeMethod and Description
public PyObject
__add__(PyObject
the object to perform this binary operation with (the right-hand operand).
other
)

Overrides org.python.core.PyObject.__add__.

Equivalent to the standard Python __add__ method.

public int
__cmp__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PyObject.__cmp__.

Equivalent to the standard Python __cmp__ method.

public PyComplex
__complex__()

Overrides org.python.core.PyObject.__complex__.

Equivalent to the standard Python __complex__ method.

public boolean
__contains__(PyObject
the element to search for in this container.
o
)

Overrides org.python.core.PyObject.__contains__.

Equivalent to the standard Python __contains__ method.

public PyObject
__eq__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PySequence.__eq__.

Equivalent to the standard Python __eq__ method.

public PyFloat
__float__()

Overrides org.python.core.PyObject.__float__.

Equivalent to the standard Python __float__ method.

public PyObject
public PyObject
__ge__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PySequence.__ge__.

Equivalent to the standard Python __ge__ method.

public PyTuple
public PyObject
__gt__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PySequence.__gt__.

Equivalent to the standard Python __gt__ method.

public PyObject
__int__()

Overrides org.python.core.PyObject.__int__.

Equivalent to the standard Python __int__ method.

public PyObject
__invert__()

Overrides org.python.core.PyObject.__invert__.

Equivalent to the standard Python __invert__ method.

public PyObject
__le__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PySequence.__le__.

Equivalent to the standard Python __le__ method.

public int
__len__()

Overrides org.python.core.PyObject.__len__.

Equivalent to the standard Python __len__ method.

public PyObject
__long__()

Overrides org.python.core.PyObject.__long__.

Equivalent to the standard Python __long__ method.

public PyObject
__lt__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PySequence.__lt__.

Equivalent to the standard Python __lt__ method.

public PyObject
__mod__(PyObject
the object to perform this binary operation with (the right-hand operand).
other
)

Overrides org.python.core.PyObject.__mod__.

Equivalent to the standard Python __mod__ method

public PyObject
__mul__(PyObject
the object to perform this binary operation with (the right-hand operand).
o
)

Overrides org.python.core.PyObject.__mul__.

Equivalent to the standard Python __mul__ method.

public PyObject
__ne__(PyObject
the object to compare this with.
other
)

Overrides org.python.core.PySequence.__ne__.

Equivalent to the standard Python __ne__ method.

public PyObject
__neg__()

Overrides org.python.core.PyObject.__neg__.

Equivalent to the standard Python __neg__ method.

public PyObject
__pos__()

Overrides org.python.core.PyObject.__pos__.

Equivalent to the standard Python __pos__ method.

public PyString
__repr__()

Overrides org.python.core.PyObject.__repr__.

Equivalent to the standard Python __repr__ method.

public PyObject
__rmul__(PyObject
the object to perform this binary operation with (the left-hand operand).
o
)

Overrides org.python.core.PyObject.__rmul__.

Equivalent to the standard Python __rmul__ method.

public PyString
__str__()

Overrides org.python.core.PyObject.__str__.

Equivalent to the standard Python __str__ method.

public Object
__tojava__(Class<?>
the Class to convert this PyObject to.
c
)

Overrides org.python.core.PySequence.__tojava__.

Equivalent to the Jython __tojava__ method.

public PyUnicode
protected final int

Returns:

count of occurrences
_count
(String
substring to find.
sub
,
PyObject
start of slice.
startObj
,
PyObject
end of slice.
endObj
)

Helper common to the Python and Java API returning the number of occurrences of a substring.

protected final int

Returns:

index of sub in this object or -1 if not found.
_find
(String
substring to find.
sub
,
PyObject
start of slice.
startObj
,
PyObject
end of slice.
endObj
)

Helper common to the Python and Java API returning the index of the substring or -1 for not found.

protected int

Returns:

index of leftmost non-whitespace character or right if they all are.
_findLeft
(int
rightmost extent of string search
right
)

Helper for strip, lstrip implementation, when stripping whitespace.

private int

Returns:

index of leftmost character not in stripChars or right if they all are.
_findLeft
(String
specifies set of characters to strip
stripChars
,
int
rightmost extent of string search
right
)

Helper for strip, lstrip implementation, when stripping specified characters.

protected int

Returns:

index of rightmost non-whitespace character or -1 if they all are.
_findRight
()

Helper for strip, rstrip implementation, when stripping whitespace.

private int

Returns:

index of rightmost character not in stripChars or -1 if they all are.
_findRight
(String
specifies set of characters to strip
stripChars
)

Helper for strip, rstrip implementation, when stripping specified characters.

private boolean
_isalnum(char ch)

private boolean
_isalpha(char ch)

private boolean
_isdecimal(char ch)

private boolean
_isdigit(char ch)

private boolean
_islower(char ch)

private boolean
_isspace(char ch)

private boolean
_isupper(char ch)

protected final String

Returns:

a new String, stripped of the whitespace characters/bytes
_lstrip
()

Implementation of Python str.lstrip() common to exposed and Java API, when stripping whitespace.

protected final String

Returns:

a new String, stripped of the specified characters/bytes
_lstrip
(String
characters to strip or null
stripChars
)

Implementation of Python str.lstrip() common to exposed and Java API.

protected final PyString

Returns:

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

Helper common to the Python and Java API for str.replace, returning a new string equal to this string with ocurrences of oldPiece replaced by newPiece, up to a maximum of count occurrences, or all of them.

protected final int

Returns:

index of sub in this object or -1 if not found.
_rfind
(String
substring to find.
sub
,
PyObject
start of slice.
startObj
,
PyObject
end of slice.
endObj
)

Helper common to the Python and Java API returning the last index of the substring or -1 for not found.

protected final PyList

Returns:

list(str) result
_rsplit
(String
string to use as separator (or null if to split on whitespace)
sep
,
int
maximum number of splits to make (there may be maxsplit+1 parts).
maxsplit
)

Implementation of Python str.rsplit() common to exposed and Java API returning a PyList of PyStrings.

protected final String

Returns:

a new String, stripped of the whitespace characters/bytes
_rstrip
()

Implementation of Python str.rstrip() common to exposed and Java API, when stripping whitespace.

protected final String

Returns:

a new String, stripped of the specified characters/bytes
_rstrip
(String
characters to strip or null
stripChars
)

Implementation of Python str.rstrip() common to exposed and Java API.

protected final PyList

Returns:

list(str) result
_split
(String
string to use as separator (or null if to split on whitespace)
sep
,
int
maximum number of splits to make (there may be maxsplit+1 parts).
maxsplit
)

Implementation of Python str.split() common to exposed and Java API returning a PyList of PyStrings.

protected final String

Returns:

a new String, stripped of the whitespace characters/bytes
_strip
()

Implementation of Python str.strip() common to exposed and Java API, when stripping whitespace.

protected final String

Returns:

a new String, stripped of the specified characters/bytes
_strip
(String
characters to strip or null
stripChars
)

Implementation of Python str.strip() common to exposed and Java API.

private final String

Returns:

transformed byte string
_translate
(String
of character (byte) translations (or null)
table
,
String
set of characters to remove (or null)
deletechars
)

Helper common to the Python and Java API implementing 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, which must be equivalent to a string of length 256 (if it is not null).

private BigInteger
asciiToBigInteger(int base, boolean isLong)

public double
asDouble()

Overrides org.python.core.PyObject.asDouble.

Convert this object into a double.

public int
asInt()

Overrides org.python.core.PyObject.asInt.

Convert this object into an int.

public long
asLong()

Overrides org.python.core.PyObject.asLong.

Convert this object into a long.

public String
private void
asNumberCheck(String methodName, String description)

public String
public String
private static String

Returns:

coerced value or null
asU16BytesNullOrError
(PyObject
to coerce to a String or null
obj
,
String
of method
name
)

Return a String equivalent to the argument according to the calling conventions of methods that accept as a byte string anything bearing the buffer interface, or accept PyNone, but not a unicode.

protected static String

Returns:

coerced value
asU16BytesOrError
(PyObject
to coerce to a String
obj
)

Return a String equivalent to the argument.

private static String

Returns:

coerced value or null if it can't be
asU16BytesOrNull
(PyObject
to coerce to a String
obj
)

Return a Java String that is the Jython-internal equivalent of the byte-like argument (a str or any object that supports a one-dimensional byte buffer).

private PyUnicode

Returns:

this as a unicode using the default encoding.
asUnicode
()

Decode this str object to a unicode, like __unicode__() but without the possibility it will be overridden.

private PyUnicode

Returns:

the slice as a unicode using the default encoding.
asUnicode
(PyObject
start index (or null or None)
startObj
,
PyObject
end index (or null or None)
endObj
)

Decode a slice of this str object to a unicode, using Python slice semantics and the default encoding.

private PyComplex

Returns:

the value
atocx
()

Convert this PyString to a complex value according to Python rules.

public double

Returns:

the value
atof
()

Convert this PyString to a floating-point value according to Python rules.

private static double

Returns:

non-numeric result (if valid)
atofSpecials
(String
to convert
s
)

Conversion for non-numeric floats, accepting signed or unsigned "inf" and "nan", in any case.

public int
atoi()

public int
atoi(int base)

public PyLong
atol()

public PyLong
atol(int base)

protected String

Returns:

the formatted string based on the arguments
buildFormattedString
(PyObject[]
to be interpolated into the string
args
,
String[]
for the trailing args
keywords
,
MarkupIterator
when used nested, null if subject is this PyString
enclosingIterator
,
String
the format string when enclosingIterator is not null
value
)

Implements PEP-3101 {}-formatting methods str.format() and unicode.format().

public String
public String
center(int width)

public char
charAt(int
the index of the char value to be returned
index
)

Overrides org.python.core.PyBaseString.charAt.

Implements java.lang.CharSequence.charAt.

Returns the char value at the specified index.

pack-priv static boolean

Returns:

true if and only if every character has a code less than 2^width
charsFitWidth
(String
string to test
s
,
int
number of bits within which each character must fit (<16)
width
)

Determine whether a Java String consists entirely of characters in the range 0 to 2width-1.

protected final int

Returns:

index if non-negative
checkIndex
(int
to check
index
)

A little helper for converting str.find to str.index that will raise ValueError("substring not found") if the argument is negative, otherwise passes the argument through.

private static String
coerce(PyObject o)

Interpret the object as a Java String representing bytes or return null.

public int

Returns:

count of occurrences.
count
(PyObject
substring to find.
sub
)

Return the number of non-overlapping occurrences of substring sub.

public int

Returns:

count of occurrences.
count
(PyObject
substring to find.
sub
,
PyObject
start of slice.
start
)

Return the number of non-overlapping occurrences of substring sub in the range [start:].

public int

Returns:

count of occurrences.
count
(PyObject
substring to find.
sub
,
PyObject
start of slice.
start
,
PyObject
end of slice.
end
)

Return the number of non-overlapping occurrences of substring sub in the range [start:end].

public int
count(String sub)

Equivalent to count(PyObject) specialized to String.

public int
count(String sub, PyObject start)

Equivalent to count(PyObject, PyObject) specialized to String.

public int
count(String sub, PyObject start, PyObject end)

Equivalent to count(PyObject, PyObject, PyObject) specialized to String .

public PyString

Returns:

instance wrapping str
createInstance
(String
to wrap
str
)

Create an instance of the same type as this object, from the Java String given as argument.

protected PyString

Returns:

instance wrapping str
createInstance
(String
Java string representing the characters (as Java UTF-16).
str
,
boolean
is ignored in PyString (effectively true).
isBasic
)

Create an instance of the same type as this object, from the Java String given as argument.

public PyObject
public PyObject
decode(String encoding)

public PyObject
decode(String encoding, String errors)

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

public String
public String
encode(String encoding)

public String
encode(String encoding, String errors)

public static String
encode_UnicodeEscape(String str, boolean use_quotes)

pack-priv static String

Returns:

encoded string (possibly the same string if unchanged)
encode_UnicodeEscape
(String str, char
'"' or '\'' use that, '?' = let Python choose, 0 or anything = no quotes
quote
)

The inner logic of the string __repr__ producing an ASCII representation of the target string, optionally in quotations.

public boolean

Returns:

true if this string slice ends with a specified suffix, otherwise false.
endswith
(PyObject
string to check for (or a PyTuple of them).
suffix
)

Equivalent to the Python str.endswith method, testing whether a string ends with a specified suffix.

public boolean

Returns:

true if this string slice ends with a specified suffix, otherwise false.
endswith
(PyObject
string to check for (or a PyTuple of them).
suffix
,
PyObject
start of slice.
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:].

public boolean

Returns:

true if this string slice ends with a specified suffix, otherwise false.
endswith
(PyObject
string to check for (or a PyTuple of them).
suffix
,
PyObject
start of slice.
start
,
PyObject
end of slice.
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].

public String
public String
expandtabs(int tabsize)

public int

Returns:

index of sub in this object or -1 if not found.
find
(PyObject
substring to find.
sub
)

Return the lowest index in the string where substring sub is found.

public int

Returns:

index of sub in this object or -1 if not found.
find
(PyObject
substring to find.
sub
,
PyObject
start of slice.
start
)

Return the lowest index in the string where substring sub is found, such that sub is contained in the slice s[start:].

public int

Returns:

index of sub in this object or -1 if not found.
find
(PyObject
substring to find.
sub
,
PyObject
start of slice.
start
,
PyObject
end of slice.
end
)

Return the lowest index in the string where substring sub is found, such that sub is contained in the slice s[start:end].

public int
find(String sub)

Equivalent to find(PyObject) specialized to String.

public int
find(String sub, PyObject start)

Equivalent to find(PyObject, PyObject) specialized to String.

public int
find(String sub, PyObject start, PyObject end)

Equivalent to find(PyObject, PyObject, PyObject) specialized to String.

public static PyString

Returns:

PyString for those bytes
fromInterned
(String
String representing bytes
interned
)

Creates a PyString from an already interned String representing bytes.

protected PyString

Returns:

new object.
fromSubstring
(int
first included character.
begin
,
int
first excluded character.
end
)

Return a new object of the same type as this one equal to the slice [begin:end].

public synchronized PyBuffer

Returns:

the requested buffer
getBuffer
(int
consumer requirements
flags
)

Implements org.python.core.BufferProtocol.getBuffer.

Return a read-only buffer view of the contents of the string, treating it as a sequence of unsigned bytes.

private static synchronized Pattern
getComplexPattern()

Return the (lazily) compiled regular expression for a Python complex number.

private BaseBuffer
getExistingBuffer(int flags)

Helper for getBuffer(int) that tries to re-use an existing exported buffer, or returns null if can't.

private PyObject

Returns:

the object designated or null.
getFieldObject
(String
to interpret.
fieldName
,
boolean
true if the field name is from a PyString, false for PyUnicode.
bytes
,
PyObject[]
argument list (positional then keyword arguments).
args
,
String[]
naming the keyword arguments.
keywords
)

Return the object referenced by a given field name, interpreted in the context of the given argument list, containing positional and keyword arguments.

private static synchronized Pattern
getFloatPattern()

Return the (lazily) compiled regular expression that matches all valid a Python float() arguments, in which Group 1 captures the number, stripped of white space.

public int
getInt(int i)

protected PyObject
getslice(int
the position of the first element.
start
,
int
one more than the position of the last element.
stop
,
int
the step size.
step
)

Implements abstract org.python.core.PySequence.getslice.

Returns a range of elements from the sequence.

public String
public int
hashCode()

Overrides org.python.core.PyObject.hashCode.

Returns a hash code value for this object.

private static int
hexescape(StringBuilder partialDecode, String errors, int digits, int hexDigitStart, String str, int size, String errorMessage)

public int

Returns:

index of sub in this object.
index
(PyObject
substring to find.
sub
)

Return the lowest index in the string where substring sub is found.

public int

Returns:

index of sub in this object.
index
(PyObject
substring to find.
sub
,
PyObject
start of slice.
start
)

Return the lowest index in the string where substring sub is found, such that sub is contained in the slice s[start:].

public int

Returns:

index of sub in this object.
index
(PyObject
substring to find.
sub
,
PyObject
start of slice.
start
,
PyObject
end of slice.
end
)

Return the lowest index in the string where substring sub is found, such that sub is contained in the slice s[start:end].

public int
index(String sub)

Equivalent to index(PyObject) specialized to String.

public int
index(String sub, PyObject start)

Equivalent to index(PyObject, PyObject) specialized to String.

public int
index(String sub, PyObject start, PyObject end)

Equivalent to index(PyObject, PyObject, PyObject) specialized to String .

public String
public boolean
public boolean
public boolean

Returns:

true
isBasicPlane
()

Determine whether the string consists entirely of basic-plane characters.

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public PyString
public int
length()

Overrides org.python.core.PyBaseString.length.

Implements java.lang.CharSequence.length.

Returns the length of this character sequence.

public String
ljust(int width)

public String
ljust(int width, String padding)

public String
public String

Returns:

a new String, stripped of the whitespace characters/bytes
lstrip
()

Equivalent of Python str.lstrip() with no argument, meaning strip whitespace.

public String

Returns:

a new String, stripped of the specified characters/bytes
lstrip
(String
characters to strip from the left end of this str/bytes, or null
stripChars
)

Equivalent of Python str.lstrip().

public PyObject

Returns:

a new PyString (or PyUnicode), stripped of the specified characters/bytes
lstrip
(PyObject
characters to strip from the left end of this str/bytes, or null
stripChars
)

Equivalent of Python str.lstrip().

private static String

Returns:

the message
nonByteStringMsg
(String
problematic string
s
)

Create the dreaded "non-byte value" error message.

private static String
padding(int n, char pad)

private static char
parse_fillchar(String function, String fillchar)

public PyTuple

Returns:

tuple of parts
partition
(PyObject
str, unicode or object implementing BufferProtocol
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.

pack-priv static TextFormatter

Returns:

a formatter ready to use, or null if the type is not a string format type.
prepareFormatter
(InternalFormat.Spec
a parsed PEP-3101 format specification.
spec
)

Common code for PyString and PyUnicode to prepare a TextFormatter from a parsed specification.

protected PyObject
pyget(int
index of element to return.
i
)

Implements abstract org.python.core.PySequence.pyget.

Returns the element of the sequence at the given index.

private void
renderField(PyObject
to format.
fieldObj
,
String
specification to apply.
formatSpec
,
StringBuilder
to which the result will be appended.
result
)

Append to a formatting result, the presentation of one object, according to a given format specification and the object's __format__ method.

protected PyObject
repeat(int
the number of times to repeat the sequence.
count
)

Implements abstract org.python.core.PySequence.repeat.

Returns a (concrete subclass of) PySequence that repeats the given sequence, as in the implementation of __mul__ for strings.

public PyString

Returns:

PyString (or PyUnicode if any string is one), this string after replacements.
replace
(PyObject
to replace where found.
oldPiece
,
PyObject
replacement text.
newPiece
)

Equivalent to Python str.replace(old, new), returning a copy of the string with all occurrences of substring old replaced by new.

public PyString

Returns:

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

Equivalent to Python str.replace(old, new[, count]), returning a copy of the string with all occurrences of substring old replaced by new.

public int

Returns:

index of sub in this object or -1 if not found.
rfind
(PyObject
substring to find.
sub
)

Return the highest index in the string where substring sub is found.

public int

Returns:

index of sub in this object or -1 if not found.
rfind
(PyObject
substring to find.
sub
,
PyObject
start of slice.
start
)

Return the highest index in the string where substring sub is found, such that sub is contained in the slice s[start:].

public int

Returns:

index of sub in this object or -1 if not found.
rfind
(PyObject
substring to find.
sub
,
PyObject
start of slice.
start
,
PyObject
end of slice.
end
)

Return the highest index in the string where substring sub is found, such that sub is contained in the slice s[start:end].

public int
rfind(String sub)

Equivalent to find(PyObject) specialized to String.

public int
rfind(String sub, PyObject start)

Equivalent to find(PyObject, PyObject) specialized to String.

public int
rfind(String sub, PyObject start, PyObject end)

Equivalent to find(PyObject, PyObject, PyObject) specialized to String.

public int

Returns:

index of sub in this object.
rindex
(PyObject
substring to find.
sub
)

Return the highest index in the string where substring sub is found.

public int

Returns:

index of sub in this object.
rindex
(PyObject
substring to find.
sub
,
PyObject
start of slice.
start
)

Return the highest index in the string where substring sub is found, such that sub is contained in the slice s[start:].

public int

Returns:

index of sub in this object.
rindex
(PyObject
substring to find.
sub
,
PyObject
start of slice.
start
,
PyObject
end of slice.
end
)

Return the highest index in the string where substring sub is found, such that sub is contained in the slice s[start:end].

public int
rindex(String sub)

Equivalent to rindex(PyObject) specialized to String.

public int
rindex(String sub, PyObject start)

Equivalent to rindex(PyObject, PyObject) specialized to String.

public int
rindex(String sub, PyObject start, PyObject end)

Equivalent to rindex(PyObject, PyObject, PyObject) specialized to String.

public String
rjust(int width)

public PyTuple

Returns:

tuple of parts
rpartition
(PyObject
str, unicode or object implementing BufferProtocol
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.

public PyList

Returns:

list(str) result
rsplit
()

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

public PyList

Returns:

list(str) result
rsplit
(String
string to use as separator (or null if to split on whitespace)
sep
)

Equivalent to Python str.rsplit(), splitting on a specified string.

public PyList

Returns:

list(str) result
rsplit
(String
string to use as separator (or null if to split on whitespace)
sep
,
int
maximum number of splits to make (there may be maxsplit+1 parts).
maxsplit
)

Equivalent to Python str.rsplit(), splitting on a specified string.

public PyList

Returns:

list(str) result
rsplit
(PyObject
string to use as separator (or null if to split on whitespace)
sep
)

Equivalent to Python str.rsplit() returning a PyList of PyStrings (or PyUnicodes).

public PyList

Returns:

list(str) result
rsplit
(PyObject
string to use as separator (or null if to split on whitespace)
sep
,
int
maximum number of splits to make (there may be maxsplit+1 parts).
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.

protected PyList

Returns:

PyList of split sections
rsplitfields
(int
limit on the number of splits (if >=0)
maxsplit
)

Helper function for .rsplit, in str and (when overridden) in unicode, splitting on white space and returning a list of the separated parts.

private PyList

Returns:

PyList of split sections
rsplitfields
(String
at occurrences of which this string should be split
sep
,
int
limit on the number of splits (if >=0)
maxsplit
)

Helper function for .rsplit, in str and unicode, returning a list of the separated parts, in the reverse order of their occurrence in this string.

public String

Returns:

a new String, stripped of the whitespace characters/bytes
rstrip
()

Equivalent of Python str.rstrip() with no argument, meaning strip whitespace.

public String

Returns:

a new String, stripped of the specified characters/bytes
rstrip
(String
characters to strip from either end of this str/bytes, or null
stripChars
)

Equivalent of Python str.rstrip().

public PyObject

Returns:

a new PyString (or PyUnicode), stripped of the specified characters/bytes
rstrip
(PyObject
characters to strip from the right end of this str/bytes, or null
stripChars
)

Equivalent of Python str.rstrip().

public PyList

Returns:

list(str) result
split
()

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

public PyList

Returns:

list(str) result
split
(String
string to use as separator (or null if to split on whitespace)
sep
)

Equivalent to Python str.split(), splitting on a specified string.

public PyList

Returns:

list(str) result
split
(String
string to use as separator (or null if to split on whitespace)
sep
,
int
maximum number of splits to make (there may be maxsplit+1 parts).
maxsplit
)

Equivalent to Python str.split(), splitting on a specified string.

public PyList

Returns:

list(str) result
split
(PyObject
string to use as separator (or null if to split on whitespace)
sep
)

Equivalent to Python str.split() returning a PyList of PyStrings (or PyUnicodes).

public PyList

Returns:

list(str) result
split
(PyObject
string to use as separator (or null if to split on whitespace)
sep
,
int
maximum number of splits to make (there may be maxsplit+1 parts).
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.

protected PyList

Returns:

PyList of split sections
splitfields
(int
limit on the number of splits (if >=0)
maxsplit
)

Helper function for .split, in str and (when overridden) in unicode, splitting on white space and returning a list of the separated parts.

private PyList

Returns:

PyList of split sections
splitfields
(String
at occurrences of which this string should be split
sep
,
int
limit on the number of splits (if >=0)
maxsplit
)

Helper function for .split and .replace, in str and unicode, returning a list of the separated parts.

public PyList
public PyList
splitlines(boolean keepends)

public boolean

Returns:

true if this string slice starts with a specified prefix, otherwise false.
startswith
(PyObject
string to check for (or a PyTuple of them).
prefix
)

Equivalent to the Python str.startswith method testing whether a string starts with a specified prefix.

public boolean

Returns:

true if this string slice starts with a specified prefix, otherwise false.
startswith
(PyObject
string to check for (or a PyTuple of them).
prefix
,
PyObject
start of slice.
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:].

public boolean

Returns:

true if this string slice starts with a specified prefix, otherwise false.
startswith
(PyObject
string to check for (or a PyTuple of them).
prefix
,
PyObject
start of slice.
start
,
PyObject
end of slice.
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].

private static boolean
storeUnicodeCharacter(int value, StringBuilder partialDecode)

pack-priv final PyObject
pack-priv final int
pack-priv final boolean
pack-priv final PyObject
pack-priv final PyObject
pack-priv final PyObject
pack-priv final PyObject
pack-priv final PyTuple
pack-priv final PyObject
pack-priv final PyObject
pack-priv final int
pack-priv final PyObject
pack-priv final int
pack-priv final PyObject
public PyObject
pack-priv final PyObject
pack-priv final PyObject
pack-priv final PyString
pack-priv final PyObject
pack-priv final PyString
pack-priv final PyObject
pack-priv final PyObject
pack-priv final String
pack-priv final String
str_center(int width, String fillchar)

pack-priv final int
str_count(PyObject subObj, PyObject start, PyObject end)

pack-priv final PyObject
str_decode(PyObject[] args, String[] keywords)

pack-priv final String
str_encode(PyObject[] args, String[] keywords)

pack-priv final boolean
str_endswith(PyObject suffix, PyObject startObj, PyObject endObj)

pack-priv final String
str_expandtabs(int tabsize)

pack-priv final int
str_find(PyObject subObj, PyObject start, PyObject end)

pack-priv final PyObject
str_format(PyObject[] args, String[] keywords)

pack-priv final int
str_index(PyObject subObj, PyObject start, PyObject end)

pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final boolean
pack-priv final PyString
pack-priv final String
str_ljust(int width, String fillchar)

pack-priv final String
pack-priv final PyObject
pack-priv static PyObject
str_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords)

pack-priv final PyTuple
pack-priv final PyString
str_replace(PyObject oldPieceObj, PyObject newPieceObj, int count)

pack-priv final int
str_rfind(PyObject subObj, PyObject start, PyObject end)

pack-priv final int
str_rindex(PyObject subObj, PyObject start, PyObject end)

pack-priv final String
str_rjust(int width, String fillchar)

pack-priv final PyTuple
pack-priv final PyList
str_rsplit(PyObject sepObj, int maxsplit)

pack-priv final PyObject
pack-priv final PyList
str_split(PyObject sepObj, int maxsplit)

pack-priv final PyList
str_splitlines(boolean keepends)

pack-priv final boolean
str_startswith(PyObject prefix, PyObject startObj, PyObject endObj)

pack-priv final PyObject
pack-priv final String
pack-priv final String
pack-priv final String
str_translate(PyObject tableObj, PyObject deletecharsObj)

pack-priv final String
pack-priv final String
str_zfill(int width)

public String

Returns:

a new String, stripped of the whitespace characters/bytes
strip
()

Equivalent of Python str.strip() with no argument, meaning strip whitespace.

public String

Returns:

a new String, stripped of the specified characters/bytes
strip
(String
characters to strip from either end of this str/bytes, or null
stripChars
)

Equivalent of Python str.strip().

public PyObject

Returns:

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

Equivalent of Python str.strip().

public CharSequence
subSequence(int
the start index, inclusive
start
,
int
the end index, exclusive
end
)

Overrides org.python.core.PyBaseString.subSequence.

Implements java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence.

public String

Returns:

the specified substring.
substring
(int
the beginning index, inclusive.
start
,
int
the ending index, exclusive.
end
)

Return a substring of this object as a Java String.

public String
public String
public byte[]

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.
toBytes
()

public int[]
private static double

Returns:

value of s
toComplexPart
(String
to interpret
s
)

Helper for interpreting each part (real and imaginary) of a complex number expressed as a string in atocx(String).

public String
toString()

Overrides org.python.core.PyObject.toString.

Implements java.lang.CharSequence.toString.

Returns a string containing the characters in this sequence in the same order as this sequence.

public String

Returns:

transformed byte string
translate
(PyObject
of character (byte) translations (or null)
table
)

Equivalent to Python str.translate returning a copy of this string where the characters have been mapped through the translation table.

public String

Returns:

transformed byte string
translate
(PyObject
of character (byte) translations (or null)
table
,
PyObject
set of characters to remove (or null)
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.

public String
translate(String table)

Equivalent to translate(PyObject) specialized to String.

public String
translate(String table, String deletechars)

Equivalent to translate(PyObject, PyObject) specialized to String.

protected int[]

Returns:

a 4 element array of two range-safe indices, and two original indices.
translateIndices
(PyObject
Python start of slice
startObj
,
PyObject
Python end of slice
endObj
)

Many of the string methods deal with slices specified using Python slice semantics: endpoints, which are PyObjects, may be null or None (meaning default to one end or the other) or may be negative (meaning "from the end").

pack-priv final PyUnicode
pack-priv final PyTuple
pack-priv final PyTuple
protected String
unsupportedopMessage(String op, PyObject o2)

Overrides org.python.core.PySequence.unsupportedopMessage.

Return sequence-specific error messages suitable for substitution.

public String
public String
zfill(int width)