Skip to content

Commit 84f7fcd

Browse files
committed
Edited copy and cleaned up links.
1 parent 729c6a8 commit 84f7fcd

2 files changed

Lines changed: 25 additions & 20 deletions

File tree

concepts/string-methods/about.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
# String Methods in Python
22

3-
A string (`str`) in Python is a sequence of Unicode code points which
4-
include letters, numbers, symbols, punctuation, etc. Strings
5-
implement all of the [common sequence operations][types seq common],
6-
along with iteration using the `for item in <string>` syntax.
3+
A `str` is an [immutable sequence][text sequence] of [Unicode code points][unicode code points].
4+
These could include letters, diacritical marks, positioning characters, numbers, currecy symbols, emoji, punctuation, space and line break characters, and more.
75

8-
Python provides several useful methods that you can use to manipulate
9-
strings. These string methods can be used for cleaning, splitting, translating,
10-
or otherwise working with the `str` type. New strings can be created based
11-
on method arguments, and/or additional information can be returned. Strings
12-
can be concatenated using the `+` operator or with `str.join()`.
6+
Strings implement all [common sequence operations][common sequence operations], and can be iterated through using `for item in <string>` or `for index, item in enumerate(<string>)` syntax.
7+
Strings can be concatenated with `+`, or via `<str>.join(<iterable>)`, split via `<str>.split(<separator>)`, and offer multiple types of formatting.
138

14-
Some of the more commonly used methods include:
9+
To further work with strings, Python provides a rich set of [string methods][str-methods] that can assist with searching, cleaning, transforming, translating, and many other operations.
10+
11+
Some of the more commonly used `str` methods include:
1512

1613
- Checking for prefixes/suffixes with `startswith()` and `endswith()`
1714
- Altering string casing with methods like `upper()`, `lower()`, and `swapcase()`
1815
- Removing leading or trailing characters from a string using `strip()`, `lstrip()`, or `rstrip()`
1916
- Replacing substrings with the `replace()` method
2017
- Checking for the existence of a substring with `in`
21-
- Concatenating strings with the `+` operator or `str.join()`
2218

2319
The `str` type is _immutable_, so all of these methods will return a new `str` instead of modifying the existing one.
2420

25-
For more information, you can check out the [official documentation][official documentation].
21+
For more information, you can check out the strings [informal tutorial][informal tutorial] or the [`str` docs][str-methods].
2622

27-
[types seq common]: https://docs.python.org/3/library/stdtypes.html#typesseq-common
28-
[official documentation]: https://docs.python.org/3/library/stdtypes.html#string-methods
23+
[common sequence operations]: https://docs.python.org/3/library/stdtypes.html#common-sequence-operations
24+
[text sequence]: https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str
25+
[unicode code points]: https://stackoverflow.com/questions/27331819/whats-the-difference-between-a-character-a-code-point-a-glyph-and-a-grapheme
26+
[informal tutorial]: https://docs.python.org/3/tutorial/introduction.html#strings
27+
[str-methods]: https://docs.python.org/3/library/stdtypes.html#string-methods
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# Introduction
22

3-
Python provides several useful methods that can be used to manipulate strings.
4-
These methods can be used for cleaning, splitting, translating, or otherwise working with any object of type `str`.
5-
Strings can be concatenated using the `+` operator or with `str.join()`.
6-
Strings also implement all common sequence operations and can be iterated through using the `for item in <string>` syntax.
3+
A `str` in Python is an [immutable sequence][text sequence] of [Unicode code points][unicode code points].
4+
These could include letters, diacritical marks, positioning characters, numbers, currecy symbols, emoji, punctuation, space and line break characters, and more.
75

8-
Strings are immutable, meaning the value of a `str` object in memory cannot change.
9-
That means any functions or methods that operate on a `str` object will return a _new instance_ or copy of that `str`, instead of modifying the original.
6+
Strings implement all [common sequence operations][common sequence operations], and can be iterated through using `for item in <string>` or `for index, item in enumerate(<string>)` syntax.
7+
Strings can be concatenated with `+`, or via `<str>.join()`, split via `<str>.split(<separator>)`, and offer multiple types of formatting.
8+
To further work with strings, Python provides a rich set of [string methods][str-methods] that can assist with searching, cleaning, transforming, translating, and many other operations.
9+
10+
Being immutable, a `str` object's value in memory doesn't change; methods that appear to modify a string return a new copy or instance of `str`.
11+
12+
[text sequence]: https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str
13+
[unicode code points]: https://stackoverflow.com/questions/27331819/whats-the-difference-between-a-character-a-code-point-a-glyph-and-a-grapheme
14+
[common sequence operations]: https://docs.python.org/3/library/stdtypes.html#common-sequence-operations
15+
[str-methods]: https://docs.python.org/3/library/stdtypes.html#string-methods

0 commit comments

Comments
 (0)