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
/// ```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:
/// print(i * i)
/// except:
/// break
/// int_numbers.append(int(num))
/// except ValueError as e:
/// print(f"Couldn't convert to integer: {e}")
/// ```
///
/// Use instead:
/// ```python
/// string_numbers: list[str] = ["1", "2", "three", "4", "5"]
///
/// int_numbers: list[int] = []
/// try:
/// for i in range(10):
/// print(i * i)
/// except:
/// break
/// for num in string_numbers:
/// int_numbers.append(int(num))
/// except ValueError as e
/// print(f"Couldn't convert to integer: {e}")
/// ```
///
/// ## Options