|
9 | 9 |
|
10 | 10 | This project has been inspired by `'strip-hints'` and `'py-backwards'` but it is |
11 | 11 | now based on the Python 3.9+ standard library's `'ast.unparse()'`. More specifically |
12 | | -it is using `'ast_comments'` to keep the comments. The implementation wants to make |
13 | | -it very easy so that you can add your own source code transformations to support |
| 12 | +it is optionally using `'ast_comments'` to keep the comments. The implementation wants to |
| 13 | +make it very easy so that you can add your own source code transformations to support |
14 | 14 | compatibility with older python versions. |
15 | 15 |
|
16 | 16 | The `'strip-python3'` tool can extract typehints to `'*.pyi'` file containing only |
17 | 17 | the outer object-oriented interface. That allows you to ship modern typed python3 |
18 | 18 | code to older systems, possibly even having only python2 preinstalled. The extra |
19 | | -pyi however will allow to run it on older systems with a python3.6 installed. |
| 19 | +pyi however will allow to run it on older systems with a python3.6+ installed. |
20 | 20 |
|
21 | 21 | The default configuration is to strip the `*.py` file to python2 syntax that can |
22 | 22 | also work in python3 (using `__print_function__`), and (when using `-2` or `-3`) |
23 | 23 | to put a `*.pyi` file next to it containing the typehints in a syntax compatible |
24 | | -with python3.6. When not using `-2` or `-3` it just prints the type-stripped and |
25 | | -backward-transformed python script to stdout. |
| 24 | +with python3. When not using `-2` or `-3` it just prints the type-stripped and |
| 25 | +backward-transformed python script to stdout. |
| 26 | + |
| 27 | +The transformed script has not only typhints removed but a lot of library calls get replaced by python2 equivalents. Using if-def in the import section, the same code |
| 28 | +runs under python2 and python3. Optionally you can define a later python version |
| 29 | +(probably for python3.6) which reduced the number of if-def parts to ensure |
| 30 | +compatibility across python versions. |
26 | 31 |
|
27 | 32 | # references |
28 | 33 |
|
@@ -131,7 +136,7 @@ if python2 compatibility is requested. |
131 | 136 |
|
132 | 137 | If `isinstance(x, str)` is used then each is replaced by `isinstance(x, basestring)` |
133 | 138 | if python2 compatibility is requested. It does also import `basestring = str` for |
134 | | -python3 versions. |
| 139 | +python3 versions. (see [doc](doc/define-basestring.md)) |
135 | 140 |
|
136 | 141 | ## define-range |
137 | 142 |
|
|
0 commit comments