Top Description Inners Fields Constructors Methods
org.python.core

public Class PyUnicode

extends Object
implements CraftedPyObject, Key
Class Inheritance
All Implemented Interfaces
org.python.core.PyDict.Key, org.python.core.CraftedPyObject
Imports
java.lang.invoke.MethodHandles, java.math.BigInteger, java.util.Arrays, .HashSet, .Iterator, .List, .ListIterator, .NoSuchElementException, .PrimitiveIterator, .Set, .Spliterator, .Spliterators, java.util.function.Function, .IntUnaryOperator, .Supplier, java.util.regex.Matcher, .Pattern, java.util.stream.Collectors, .IntStream, .StreamSupport, org.python.base.InterpreterError, .MissingFeature, org.python.core.Exposed.Default, .Exposed.Name, .Exposed.PythonMethod, .PyObjectUtil.NoConversion, .PySequence.Delegate, .PySlice.Indices, org.python.core.stringlib.FieldNameIterator, .IntArrayBuilder, .IntArrayReverseBuilder, .InternalFormat, .InternalFormat.AbstractFormatter, .InternalFormat.FormatError, .InternalFormat.FormatOverflow, .InternalFormat.Spec, .MarkupIterator, .TextFormatter, org.python.modules.ucnhashAPI

The Python str object is implemented by both PyUnicode and Java String. All operations will produce the same result for Python, whichever representation is used. Both types are treated as an array of code points in Python.

Most strings used as names (keys) and text are quite satisfactorily represented by Java String. Java Strings are compact, but where they contain non-BMP characters, these are represented by a pair of code units. That makes certain operations (such as indexing or slicing) relatively expensive compared to Java. Accessing the code points of a String sequentially is still cheap.

By contrast, a PyUnicode is time-efficient, but each character occupies one int.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv abstract static class
PyUnicode.CodepointDelegate

A base class for the delegate of either a String or a PyUnicode, implementing __getitem__ and other index-related operations.

pack-priv static interface
PyUnicode.CodepointIterator

A ListIterator working bidirectionally in code point indices.

private static class
PyUnicode.StrFormatter

A AbstractFormatter, constructed from a Spec, with specific validations for str.__format__.

pack-priv static class
PyUnicode.StringAdapter

Wrap a Java String as a PySequence.

pack-priv class
PyUnicode.UnicodeAdapter

A class to act as the delegate implementing __getitem__ and other index-related operations.

Field Summary

Modifier and TypeField and Description
private static String
private static Pattern
private PyUnicode.UnicodeAdapter
delegate

Helper to implement __getitem__ and other index-related operations.

private static Pattern
floatPattern

Access only through getFloatPattern().

private int
hash

Cached hash of the str, lazily computed in hashCode().

private static char[]
private static final int
private static final String
private static ucnhashAPI
public static final PyType
TYPE

The type str.

protected PyType
type

The actual Python type of this PyUnicode.

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.

private final int[]
value

The implementation holds a Java int array of code points.

Constructor Summary

AccessConstructor and Description
private
PyUnicode(PyType
actual type the instance should have
type
,
boolean
if true, the array becomes the implementation array, otherwise the constructor takes a copy.
iPromiseNotToModify
,
int[]
the array of code points
codePoints
)

Construct an instance of PyUnicode, a str or a sub-class, from a given array of code points, with the option to re-use that array as the implementation.

protected
PyUnicode(PyType
actual type the instance should have
type
,
int[]
the array of code points
codePoints
)

Construct an instance of PyUnicode, a str or a sub-class, from a given array of code points.

protected
PyUnicode(int...
the array of code points
codePoints
)

Construct an instance of PyUnicode, a str or a sub-class, from the given code points.

protected
PyUnicode(IntArrayBuilder
from which to take the code points
value
)

Construct an instance of PyUnicode, a str or a sub-class, from a given IntArrayBuilder.

protected
PyUnicode(IntArrayReverseBuilder
from which to take the code points
value
)

Construct an instance of PyUnicode, a str or a sub-class, from a given IntArrayReverseBuilder.

protected
PyUnicode(PyType
actual type the instance should have
type
,
String
to have
value
)

Construct an instance of PyUnicode, a str or a sub-class, from a given Java String.

Method Summary

Modifier and TypeMethod and Description
private Object
private static Object
private boolean
private static boolean
pack-priv static final Object
__format__(Object self, Object formatSpec)

private Object
private static Object
private PyTuple
private static PyTuple
private int
private static int
private int
private static int
pack-priv static Object
__mod__(Object self, Object other)

private Object
private static Object
private Object
private static Object
private static Object
private Object
private static Object
private Object
private static Object
public Object
private final String

Returns:

transformed string
_translate
(String
of character 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 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).

pack-priv static PyUnicode.CodepointDelegate

Returns:

adapted to a sequence
adapt
(Object
to wrap or return
v
)

Adapt a Python str to a sequence of Java int values or throw an exception.

pack-priv static PyUnicode.StringAdapter

Returns:

new StringAdapter(v)
adapt
(String
to wrap
v
)

Short-cut adapt(Object) when type statically known.

pack-priv PyUnicode.UnicodeAdapter

Returns:

the delegate for sequence operations on this str
adapt
()

Short-cut adapt(Object) when type statically known.

private static int

Returns:

fill as a code point
adaptFill
(String
in which encountered
method
,
Object
alleged fill character (or null)
fill
)

Adapt a Python str intended as a fill character in justification and centring operations.

pack-priv static PyUnicode.CodepointDelegate

Returns:

adapted to a sequence
adaptRep
(String
in which encountered
method
,
Object
alleged string
replacement
)

Adapt a Python str, as by adapt(Object), that is intended as a replacement substring in str.replace(), for example.

pack-priv static PyUnicode.CodepointDelegate

Returns:

adapted to a sequence
adaptSeparator
(String
in which encountered
method
,
Object
alleged separator
sep
)

Adapt a Python str intended as a separator, as by adapt(Object).

pack-priv static Set<Integer>

Returns:

null or characters adapted to a set
adaptStripSet
(String
in which encountered
method
,
Object
characters defining the set (or None or null)
chars
)

Adapt a Python str, intended as a list of characters to strip, as by adapt(Object) then conversion to a set.

pack-priv static PyUnicode.CodepointDelegate

Returns:

adapted to a sequence
adaptSub
(String
in which encountered
method
,
Object
alleged string
sub
)

Adapt a Python str, as by adapt(Object), that is intended as a substring to find, in str.find() or str.replace(), for example.

private static BigInteger
asciiToBigInteger(String self, int base, boolean isLong)

public PySequence.OfInt

Returns:

the code point sequence
asSequence
()

The code points of this PyUnicode as a PySequence.

public static String

Returns:

String value
asString
(Object
claimed str
v
)

Present a Python str as a Java String value or raise a TypeError.

public static <
type of exception to throw
E extends PyException
>
String

Returns:

String value
asString
(Object
claimed str
v
,
Function<Object, E>
to supply the exception to throw wrapping v
exc
)

Present a qualifying object v as a Java String value or throw E.

pack-priv String

Returns:

this PyUnicode as a Java String
asString
()

Convert this PyUnicode to a Java String built from its code point values.

private PyComplex

Returns:

the value
atocx
()

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

public double
atof()

public static double

Returns:

the value
atof
(String
to convert
self
)

Convert a String 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(int base)

public int
atoi()

public static int
atoi(String self, int base)

public PyLong
atol(int base)

public PyLong
atol()

public static PyLong
atol(String self, int base)

private String

Returns:

the formatted string based on the arguments
buildFormattedString
(Object[]
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 method str.format().

pack-priv Object
pack-priv static Object
private static Object

Returns:

capitalised string
capitalize
(PyUnicode.CodepointDelegate
the self string
s
)

Inner implementation of capitalize

pack-priv Object
center(int width, Object fillchar)

pack-priv static Object
center(String self, int width, Object fillchar)

public static String
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 void
checkIndexRange(int
e.g. the start position of na iterator.
index
,
int
first in range
start
,
int
first beyond range (i.e. non-inclusive bound)
end
,
int
of sequence
len
)

Assert that 0 ≤ start ≤index ≤ end ≤ len or if not, throw an exception.

private static final int

Returns:

index if non-negative
checkIndexReturn
(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.

pack-priv static <
type of exception to throw
E extends PyException
>
String

Returns:

arg as a String
coerceToString
(Object
to coerce
arg
,
Supplier<E>
supplier for actual exception
exc
)

Coerce a Python str to a Java String, or raise a specified exception.

private static Object

Returns:

the concatenation v + w
concat
(String
first string to concatenate
v
,
String
second string to concatenate
w
)

Concatenate two String representations of str.

private static PyUnicode

Returns:

the concatenation v + w
concatUnicode
(IntStream
first string to concatenate
v
,
IntStream
second string to concatenate
w
)

Concatenate two streams of code points into a PyUnicode.

private static boolean
pack-priv static String

Returns:

converted to String
convertToString
(Object
to convert
v
)

Convert a Python str to a Java str (or throw NoConversion).

pack-priv int

Returns:

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

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

pack-priv static int
count(String self, Object sub, Object start, Object end)

private static int
private static int

Returns:

count of occurrences
count
(PyUnicode.CodepointDelegate
substring to find.
s
,
PyUnicode.CodepointDelegate
start of slice.
p
,
PySlice.Indices
end of slice.
slice
)

The inner implementation of str.count, returning the number of occurrences of a substring.

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

pack-priv Object
encode(Object[] args, String[] keywords)

pack-priv Object
encode(String self, Object[] args, String[] keywords)

pack-priv Object
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
to process
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.

private String

Returns:

a valid decimal as an encoded String
encodeDecimal
()

Deprecated
Encode unicode into a valid decimal String.
private String

Returns:

a valid decimal as an encoded String
encodeDecimalBasic
()

Encode unicode in the basic plane into a valid decimal String.

pack-priv Object

Returns:

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

pack-priv static Object
endswith(String self, Object suffix, Object start, Object end)

private static boolean
private static boolean
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Implements org.python.core.PyDict.Key.equals.

Compare for equality with another Python str, or a PyDict.
pack-priv Object
expandtabs(int tabsize)

pack-priv static Object
expandtabs(String self, int tabsize)

private static Object

Returns:

tab-expanded string
expandtabs
(PyUnicode.CodepointDelegate
the self string
s
,
int
number of spaces to tab to
tabsize
)

Inner implementation of expandtabs

pack-priv int

Returns:

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

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

pack-priv static int
find(String self, Object sub, Object start, Object end)

private static int
private static int

Returns:

the index of the occurrence or -1
find
(PyUnicode.CodepointDelegate
to be searched
s
,
PyUnicode.CodepointDelegate
the substring to look for
p
,
PySlice.Indices
of s in which to search
slice
)

Inner implementation of Python str.find().

private static int

Returns:

index of leftmost non-space character or s.length() if entirely spaces.
findLeft
(PyUnicode.CodepointDelegate s)

Helper for strip, lstrip implementation, when stripping space.

private static int

Returns:

index of leftmost non-p character or s.length() if entirely found in p.
findLeft
(PyUnicode.CodepointDelegate s, Set<Integer>
specifies set of characters to strip
p
)

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

private static int

Returns:

index of rightmost non-space character or -1 if entirely spaces.
findRight
(PyUnicode.CodepointDelegate s)

Helper for strip, rstrip implementation, when stripping space.

private static int

Returns:

index of rightmost non-p character or -1 if entirely found in p.
findRight
(PyUnicode.CodepointDelegate s, Set<Integer>
specifies set of characters to strip
p
)

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

pack-priv final Object
format(Object[] args, String[] keywords)

pack-priv static PyTuple

Returns:

a tuple of the first field name component and the rest
formatter_field_name_split
(Object
to split into components
fieldName
)

Implementation of _string.formatter_field_name_split.

pack-priv static Object

Returns:

an iterator of format tuples
formatter_parser
(Object
to parse
formatString
)

Implementation of _string.formatter_parser.

public static Object

Returns:

a Python str
fromCodePoint
(int
to code point convert
cp
)

Return a Python str representing the single character with the given code point.

pack-priv static PyUnicode

Returns:

formatted string
fromFormat
(String
format string (Java semantics)
fmt
,
Object...
arguments
args
)

Deprecated
Create a str from a format and arguments.
public static PyUnicode

Returns:

a Python str
fromJavaString
(String
to convert
s
)

Return a Python str representing the same sequence of characters as the given Java String and implemented as a PyUnicode.

private static synchronized Pattern
getComplexPattern()

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

private Object

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
,
Object[]
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.

private static PySlice.Indices

Returns:

indices of the slice
getSliceIndices
(PyUnicode.CodepointDelegate
sequence being sliced
s
,
Object
first index included
start
,
Object
first index not included
end
)

Convert slice end indices to a PySlice.

public PyType
getType()

Implements org.python.core.CraftedPyObject.getType.

The Python type of this object.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements org.python.core.PyDict.Key.hashCode.

The hash of a PyUnicode is the same as that of a Java String equal to it.
private static int
hexescape(StringBuilder partialDecode, String errors, int digits, int hexDigitStart, String str, int size, String errorMessage)

pack-priv int

Returns:

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

As find(Object, Object, Object), but throws ValueError if the substring is not found.

pack-priv static int
index(String self, Object sub, Object start, Object end)

pack-priv final boolean
pack-priv static boolean
private static boolean
pack-priv final boolean
pack-priv static boolean
private static boolean
public boolean
public static boolean
private static boolean

Returns:

whether contains no non-BMP characters
isBMP
(String
the string to test
s
)

Test whether a string contains no characters above the BMP range, that is, any characters that require surrogate pairs to represent them.

pack-priv final boolean
pack-priv static boolean
private static boolean
pack-priv final boolean
pack-priv static boolean
private static boolean
pack-priv boolean
pack-priv static boolean
private static boolean
pack-priv final boolean
pack-priv static boolean
private static boolean
private static boolean
isPythonLineSeparator(int cp)

Define what characters are to be treated as a line separator according to Python 3.

private static boolean
isPythonSpace(int cp)

Define what characters are to be treated as a space according to Python 3.

pack-priv final boolean
pack-priv static boolean
private static boolean
pack-priv final boolean
pack-priv static boolean
private static boolean
pack-priv final boolean
pack-priv static boolean
private static boolean
pack-priv Object
join(Object iterable)

pack-priv static Object
join(String self, Object iterable)

private static Object

Returns:

capitalised string
join
(PyUnicode.CodepointDelegate
the self string (separator)
s
,
Object
of strings
iterable
)

Inner implementation of join.

private static TypeError
pack-priv Object
ljust(int width, Object fillchar)

pack-priv static Object
ljust(String self, int width, Object fillchar)

pack-priv PyUnicode
pack-priv static String
lower(String self)

pack-priv Object

Returns:

a new str, left-stripped of the specified characters
lstrip
(Object
characters to strip from this str, or None
chars
)

Python str.lstrip().

pack-priv static Object
lstrip(String self, Object chars)

private static Object

Returns:

the str stripped
lstrip
(PyUnicode.CodepointDelegate
representing self
s
,
Object
to remove, or null or None
chars
)

Inner implementation of Python str.lstrip() independent of the implementation type.

private PyUnicode

Returns:

transformed string
mapChars
(IntUnaryOperator
the operation
op
)

Apply a unary operation to every character of a string and return them as a string.

private static String

Returns:

transformed string
mapChars
(String s, IntUnaryOperator
the operation
op
)

Apply a unary operation to every character of a string and return them as a string.

private static NoSuchElementException
noSuchElement(int k)

A NoSuchElementException identifying the index.

private static Object

Returns:

the padded string (or s.principal())
pad
(boolean
whether to pad at the left
left
,
PyUnicode.CodepointDelegate
the self string
s
,
boolean
whether to pad at the right
right
,
int
the minimum width to attain
width
,
int
the code point value to use as the fill
fill
)

Common code for ljust, rjust and center.

pack-priv PyTuple

Returns:

tuple of parts
partition
(Object
on which to split the string
sep
)

Python str.partition(), splits the str at the first occurrence of sep returning a PyTuple containing the part before the separator, the separator itself, and the part after the separator.

pack-priv static PyTuple
partition(String self, Object sep)

private static PyTuple

Returns:

tuple of parts or null
partition
(PyUnicode.CodepointDelegate
to be split
s
,
Object
the separator to look for
sep
)

Inner implementation of Python str.partition().

private void
renderField(Object
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.

pack-priv Object

Returns:

self string after replacements.
replace
(Object
to replace where found.
old
,
Object
replacement text.
rep
,
int
maximum number of replacements to make, or -1 meaning all of them.
count
)

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

pack-priv static Object
replace(String self, Object old, Object rep, int count)

private static Object
private static Object

Returns:

string interleaved with the replacement
replace
(PyUnicode.CodepointDelegate
delegate presenting self as code points
s
,
PyUnicode.CodepointDelegate
delegate representing the replacement string
r
,
int
limit on the number of replacements
count
)

Implementation of Python str.replace in the case where the substring to find has zero length.

private static Object

Returns:

string with the replacements
replace
(PyUnicode.CodepointDelegate
delegate presenting self as code points
s
,
PyUnicode.CodepointDelegate
delegate representing the string to replace
p
,
PyUnicode.CodepointDelegate
delegate representing the replacement string
r
,
int
limit on the number of replacements
count
)

Implementation of Python str.replace in the case where the substring to find has non-zero length, up to the limit imposed by count.

pack-priv int

Returns:

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

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

pack-priv static int
rfind(String self, Object sub, Object start, Object end)

private static int
private static int

Returns:

the index of the occurrence or -1
rfind
(PyUnicode.CodepointDelegate
to be searched
s
,
PyUnicode.CodepointDelegate
the substring to look for
p
,
PySlice.Indices
of s in which to search
slice
)

Inner implementation of Python str.rfind().

pack-priv int

Returns:

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

As rfind(Object, Object, Object), but throws ValueError if the substring is not found.

pack-priv static int
rindex(String self, Object sub, Object start, Object end)

pack-priv Object
rjust(int width, Object fillchar)

pack-priv static Object
rjust(String self, int width, Object fillchar)

pack-priv PyTuple

Returns:

tuple of parts
rpartition
(Object
on which to split the string
sep
)

Python str.rpartition(), splits the str at the last occurrence of sep.

pack-priv static PyTuple
private static PyTuple

Returns:

tuple of parts or null
rpartition
(PyUnicode.CodepointDelegate
to be split
s
,
Object
the separator to look for
sep
)

Helper to Python str.rpartition().

pack-priv PyList

Returns:

list(str) result
rsplit
(Object
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) or -1 for all possible.
maxsplit
)

Python str.rsplit([sep [, maxsplit]]) returning a PyList of str.

pack-priv static PyList
rsplit(String self, Object sep, int maxsplit)

private static PyList
rsplit(PyUnicode.CodepointDelegate s, Object sep, int maxsplit)

private static PyList

Returns:

PyList of split sections
rsplit
(PyUnicode.CodepointDelegate
delegate presenting self as code points
s
,
PyUnicode.CodepointDelegate
at occurrences of which s should be split
p
,
int
limit on the number of splits (if not <=0)
maxsplit
)

Implementation of Python str.rsplit, returning a list of the separated parts.

private static PyList

Returns:

PyList of split sections
rsplitAtSpaces
(PyUnicode.CodepointDelegate
delegate presenting self as code points
s
,
int
limit on the number of splits (if >=0)
maxsplit
)

Implementation of str.rsplit splitting on white space and returning a list of the separated parts.

pack-priv Object

Returns:

a new str, right-stripped of the specified characters
rstrip
(Object
characters to strip from this str, or None
chars
)

Python str.rstrip().

pack-priv static Object
rstrip(String self, Object chars)

private static Object

Returns:

the str stripped
rstrip
(PyUnicode.CodepointDelegate
representing self
s
,
Object
to remove, or null or None
chars
)

Inner implementation of Python str.rstrip() independent of the implementation type.

pack-priv PyList

Returns:

list(str) result
split
(Object
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) or -1 for all possible.
maxsplit
)

Python str.split([sep [, maxsplit]]) returning a PyList of str.

pack-priv static PyList
split(String self, Object sep, int maxsplit)

private static PyList
split(PyUnicode.CodepointDelegate s, Object sep, int maxsplit)

private static PyList

Returns:

PyList of split sections
split
(PyUnicode.CodepointDelegate
delegate presenting self as code points
s
,
PyUnicode.CodepointDelegate
at occurrences of which s should be split
p
,
int
limit on the number of splits (if not <=0)
maxsplit
)

Implementation of Python str.split, returning a list of the separated parts.

private static PyList

Returns:

PyList of split sections
splitAtSpaces
(PyUnicode.CodepointDelegate
delegate presenting self as code points
s
,
int
limit on the number of splits (if >=0)
maxsplit
)

Implementation of str.split splitting on white space and returning a list of the separated parts.

pack-priv PyList

Returns:

the list of lines
splitlines
(boolean
the lines in the list retain the separator that caused the split
keepends
)

Python str.splitlines([keepends]) returning a list of the lines in the string, breaking at line boundaries.

pack-priv static PyList
splitlines(String self, boolean keepends)

private static PyList
splitlines(PyUnicode.CodepointDelegate s, boolean keepends)

pack-priv Object

Returns:

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

pack-priv static Object
startswith(String self, Object prefix, Object start, Object end)

private static boolean
private static boolean
private static boolean
storeUnicodeCharacter(int value, StringBuilder partialDecode)

pack-priv Object

Returns:

a new str, stripped of the specified characters
strip
(Object
characters to strip from either end of this str, or None
chars
)

Python str.strip().

pack-priv static Object
strip(String self, Object chars)

private static Object

Returns:

the str stripped
strip
(PyUnicode.CodepointDelegate
representing self
s
,
Object
to remove, or null or None
chars
)

Inner implementation of Python str.strip() independent of the implementation type.

pack-priv PyUnicode
pack-priv static String
private static int
swapcase(int c)

pack-priv PyUnicode
pack-priv static PyUnicode
title(String self)

private static PyUnicode
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 java.lang.Object.toString.

Represent the `str` value in readable form, escaping lone surrogates.
pack-priv final Object
pack-priv static Object
translateCharmap(PyUnicode str, String errors, Object mapping)

pack-priv PyUnicode
pack-priv static String
upper(String self)

private static PyUnicode

Returns:

the str
wrap
(int[]
to wrap as a str
codePoints
)

Unsafely wrap an array of code points as a PyUnicode.

public static PyUnicode

Returns:

the str
wrap
(IntArrayBuilder
to wrap as a str
codePoints
)

Safely wrap the contents of an IntArrayBuilder of code points as a PyUnicode.

pack-priv Object
zfill(int width)

pack-priv static Object
zfill(String self, int width)

private static Object

Returns:

the filled string
zfill
(PyUnicode.CodepointDelegate
the self string
s
,
int
the achieve by inserting zeros
width
)

Inner implementation of zfill

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait