docs: fix python nix-shell example (#10841)

* docs: fix python nix-shell example

This Python code snippet depended on Python 2 which has been marked as insecure in 24.05.

I modernized the example so new users will not be surprised upon copying and pasting the snippet for exploration.

Co-authored-by: John Ericson <git@JohnEricson.me>
This commit is contained in:
Eli Flanagan 2024-06-03 17:22:50 -04:00 committed by GitHub
parent da92ad7dd2
commit bf72b78ef2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -202,14 +202,14 @@ For example, here is a Python script that depends on Python and the
```python ```python
#! /usr/bin/env nix-shell #! /usr/bin/env nix-shell
#! nix-shell -i python --packages python pythonPackages.prettytable #! nix-shell -i python3 --packages python3 python3Packages.prettytable
import prettytable import prettytable
# Print a simple table. # Print a simple table.
t = prettytable.PrettyTable(["N", "N^2"]) t = prettytable.PrettyTable(["N", "N^2"])
for n in range(1, 10): t.add_row([n, n * n]) for n in range(1, 10): t.add_row([n, n * n])
print t print(t)
``` ```
Similarly, the following is a Perl script that specifies that it Similarly, the following is a Perl script that specifies that it