OILS / demo / cpython / python-language.sh View on Github | oilshell.org

31 lines, 14 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# ./python-language.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10# https://stackoverflow.com/questions/11181519/python-whats-the-difference-between-builtin-and-builtins
11# Hm there was a lot of renaming that happened in Python 2 and 3. This isn't
12# the best comparison.
13
14dump-builtins() {
15 local py=$1
16 $py -c '
17for name in sorted(dir(__builtins__)):
18 print(name)
19' | sort > _tmp/$py.txt
20}
21
22# Hm Python 3 moved sorted(), etc. out of __builtins__?
23builtins() {
24 dump-builtins python
25 dump-builtins python3
26
27 comm _tmp/{python,python3}.txt || true
28 wc -l _tmp/{python,python3}.txt
29}
30
31"$@"