Improve PERF203 example in docs (#5634)

Closes #5624.
This commit is contained in:
Charlie Marsh 2023-07-09 22:24:46 -04:00 committed by GitHub
parent 401d172e47
commit fa1341b0db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 8 deletions

View File

@ -27,20 +27,26 @@ use crate::settings::types::PythonVersion;
/// ///
/// ## Example /// ## Example
/// ```python /// ```python
/// for i in range(10): /// string_numbers: list[str] = ["1", "2", "three", "4", "5"]
///
/// int_numbers: list[int] = []
/// for num in string_numbers:
/// try: /// try:
/// print(i * i) /// int_numbers.append(int(num))
/// except: /// except ValueError as e:
/// break /// print(f"Couldn't convert to integer: {e}")
/// ``` /// ```
/// ///
/// Use instead: /// Use instead:
/// ```python /// ```python
/// string_numbers: list[str] = ["1", "2", "three", "4", "5"]
///
/// int_numbers: list[int] = []
/// try: /// try:
/// for i in range(10): /// for num in string_numbers:
/// print(i * i) /// int_numbers.append(int(num))
/// except: /// except ValueError as e
/// break /// print(f"Couldn't convert to integer: {e}")
/// ``` /// ```
/// ///
/// ## Options /// ## Options