The package registry is still being built. The docs are live, everything else is a preview.

Edge Python

Sign In

Sign in to publish packages and pin them by sha256.


By continuing, you accept our Terms and Conditions.

@
Palette

Methods

str, bytes, list, dict, and set carry built-in methods, plus a small set on int and float. The set is curated for common operations. Missing variants are noted per section.

tuple and frozenset have no methods. (1, 2).count(1) raises AttributeError. Frozensets use the algebra operators from Set instead.

cmd + enter
HELLO
1
1
Output

String methods

Case transforms

upper, lower, capitalize, title, casefold, swapcase. title titlecases each maximal run of letters. casefold is aggressive lowercasing for caseless comparison.

cmd + enter
HELLO
hello
Hello world
Hello World
hello
hELLO wORLD
Output

Whitespace

strip, lstrip, rstrip remove whitespace, or any character in the optional string argument.

cmd + enter
hi
hi  
  hi
hello
Output

Predicates

isdigit, isalpha, isalnum, isspace, isupper, islower, istitle. All return False on an empty string. The cased predicates also require at least one cased character. isdigit is Unicode-aware.

cmd + enter
True
True
True
True
True
True
True
Output

Not provided: isascii, isidentifier, isnumeric, isdecimal, isprintable.

Search and count

find and rfind return a code-point index, or -1 on a miss. index and rindex raise ValueError on a miss. count counts non-overlapping occurrences. startswith and endswith accept a single string or a tuple of strings. All of these take optional start and end code-point bounds.

cmd + enter
True
True
2
5
3
-1
2
Output

Split, join, replace

split() with no argument (or None) splits on whitespace runs. An explicit separator splits on every occurrence, and an empty separator raises ValueError. split and rsplit take an optional maxsplit. replace(old, new) takes an optional count cap. splitlines() drops the line separators and has no keepends mode. partition and rpartition split once into a (head, sep, tail) tuple. removeprefix and removesuffix strip an affix when present.

cmd + enter
['a', 'b', 'c']
['a', 'b,c']
['a b', 'c']
['hello', 'world']
a,b,c
bbaa
bar
['a', 'b', 'c']
('foo', ':', 'bar:baz')
('foo:bar', ':', 'baz')
Output

Padding

center, ljust, rjust take (width[, fill]). zfill(width) pads with leading zeros after any sign. Widths are measured in code points, not bytes. A multi-character fill raises TypeError. expandtabs([tabsize]) replaces tabs with spaces up to the next tab stop, default 8.

cmd + enter
--abc--
hi...
...hi
00042
-0042
a   bc
**ñ**
Output

Not provided: translate, maketrans, format_map.

Formatting

str.format(*args) fills positional fields. {} auto-numbers and {0} picks an index. A spec after : uses the format mini-language. Keyword fields like {name} are not supported.

The % operator does printf-style formatting. Supported verbs are %s %r %d %i %u %x %X %o %f %F %e %E %g %G %c %%, with flags, width, and .precision. * reads the width or precision from the next argument. A tuple on the right spreads into the fields, any other value is a single argument.

cmd + enter
a and b
x-y-x
      hi
3 apples, 1.5 kg
03.10|hi    |
Output

Encoding

s.encode([encoding]) returns bytes. The encodings are "utf-8" (the default), "utf8", and "ascii". ASCII raises ValueError on non-ASCII input, and any other encoding name raises ValueError.

cmd + enter
b'caf\xc3\xa9'
b'hi'
Output

Bytes methods

decode([encoding[, errors]]) returns a string. The encodings match str.encode. The errors handler is "strict" (the default, raises ValueError on invalid UTF-8), "ignore" (drops bad bytes), or "replace" (substitutes U+FFFD).

hex() returns lowercase hex with no separator option. startswith and endswith take a single bytes value, no tuple form. find returns a byte offset or -1, and index raises ValueError on a miss. count counts non-overlapping occurrences. replace(old, new) has no count cap. split(sep) requires an explicit separator. lower and upper case-fold ASCII bytes only. strip, lstrip, rstrip trim ASCII whitespace or any byte in the optional argument. join concatenates an iterable of bytes. bytes.fromhex(s) parses a hex string, ignoring whitespace.

bytearray and memoryview do not exist.

cmd + enter
Hello
48656c6c6f
True
True
2
2
b'HeLLo'
[b'a', b'b', b'c']
b'abc'
b'hi'
b'a-b-c'
b'Hello'
�
Output

List methods

Query

index(value[, start[, end]]) returns the first match and raises ValueError on a miss. Negative bounds count from the end. count(value) counts matches. copy() returns a shallow copy.

cmd + enter
1
3
2
[1, 2, 3, 2]
[1, 2, 3, 2, 99]
Output

Mutating

These return None and mutate in place. append(x) adds one item. extend(iter) adds every item of any iterable. insert(i, x) inserts at an index. remove(x) deletes the first match and raises ValueError on a miss. pop() removes and returns the last item, pop(i) by index. Both raise IndexError when the index is invalid. sort() accepts key=fn and reverse=True and orders objects by their __lt__. reverse() flips in place. clear() empties the list.

cmd + enter
[99, 1, 2, 3, 4, 5, 6]
6 [1, 2, 3, 4, 5]
1 [2, 3, 4, 5]
Output
cmd + enter
[1, 1, 3, 4, 5]
[5, 4, 3, 1, 1]
['kiwi', 'apple', 'banana']
Output

Dict methods

Views

keys, values, items return concrete list snapshots, not live views. Later mutations of the dict do not affect a captured snapshot.

cmd + enter
['a', 'b', 'c']
[1, 2, 3]
[('a', 1), ('b', 2), ('c', 3)]
['a', 'b', 'c']
Output

Lookup

get(key) returns the value or None. get(key, default) returns default on a miss.

cmd + enter
1
None
0
Output

Mutation

update(src) merges a dict, an iterable of length-2 pairs, or keyword arguments. pop(key) removes and returns the value, raising KeyError on a miss unless a default is given. popitem() removes and returns the last-inserted (key, value) pair and raises KeyError on an empty dict. setdefault(key, default) inserts only when the key is missing and returns the stored value. clear() empties the dict in place, so aliases see the change. copy() returns a shallow copy. dict.fromkeys(iterable[, value]) builds a new dict mapping each key to value, default None.

cmd + enter
{'a': 99, 'b': 2, 'c': 3, 'e': 5}
99 {'b': 2, 'c': 3, 'e': 5}
fallback
2
{'x': 0, 'y': 0}
('e', 5)
Output

Set methods

These exist on set only. Frozensets use the operators and comparisons from Set.

Mutation

add(x) inserts. remove(x) deletes and raises KeyError on a miss. discard(x) deletes silently. pop() removes and returns an arbitrary element and raises KeyError on an empty set. update(*iterables) inserts from any number of iterables. clear() empties the set. copy() returns a shallow copy.

cmd + enter
{2, 4, 1, 3}
{4, 1, 3}
True
set()
Output

Algebra

union, intersection, difference return fresh sets and accept any number of iterable arguments. symmetric_difference takes exactly one. intersection_update, difference_update, symmetric_difference_update mutate the receiver. issubset, issuperset, isdisjoint test relations. The named methods accept any iterable, while the operator forms (|, &, -, ^) require a set or frozenset on both sides.

cmd + enter
{5, 2, 4, 1, 3}
{3}
{1, 2}
{5, 2, 4, 1}
[1, 2, 3, 4, 5]
{2, 4}
True
True
True
Output

int and float methods

int exposes bit_length() (bits needed for the absolute value, 0 for zero), bit_count() (number of set bits), and to_bytes(length=1, byteorder='big') (unsigned, OverflowError when the value does not fit or is negative). int.from_bytes(bytes, byteorder='big') is a classmethod, unsigned, raising OverflowError past the 128-bit range. float exposes is_integer().

cmd + enter
8
8
b'\x03\xe8'
b'\xe8\x03'
1000
True
False
Output

The standalone int_to_bytes, int_from_bytes, bytes_fromhex functions do similar jobs but are fixed-arity, capped at 8 bytes, and reject negative ints with ValueError.