Remove Python 2 references from the track (#3437)
* Remove Python 2 references from the track * Revert unintentional whitespace changes to test files [no important files changed]
This commit is contained in:
@@ -82,7 +82,7 @@ False
|
||||
Strings (`str`) are compared [_lexicographically_][lexographic order], using their individual Unicode code points (_the result of passing each code point in the `str` to the built-in function [`ord()`][ord], which returns an `int`_).
|
||||
If all code points in both strings match and are _**in the same order**_, the two strings are considered equal.
|
||||
This comparison is done in a 'pair-wise' fashion - first-to-first, second-to-second, etc.
|
||||
Unlike in Python 2.x, in Python 3.x, `str` and `bytes` cannot be directly coerced/compared.
|
||||
In Python 3.x, `str` and `bytes` cannot be directly coerced/compared.
|
||||
|
||||
```python
|
||||
>>> 'Python' > 'Rust'
|
||||
|
||||
@@ -149,7 +149,7 @@ Use of the `%` operator for formatting is the oldest method of string formatting
|
||||
It comes from the C language and allows the use of positional arguments to build a `str`.
|
||||
|
||||
This method has been superseded by both `f-strings` and `str.format()`, which is why the nickname for `%` formatting is _'Old Style'_.
|
||||
It can be still found in python 2 and/or legacy code.
|
||||
It can be still found in Python 2 and/or legacy code.
|
||||
While using this method will work in Python 3.x, `%` formatting is usually avoided because it can be error-prone, is less efficient, has fewer options available, and any placeholder-argument mismatch can raise an exception.
|
||||
Using the `%` operator is similar to [`printf()`][printf-style-docs], so it is also sometimes called _printf formatting_.
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ The [zen of Python (PEP 20)][the zen of python] and [What is Pythonic?][what is
|
||||
|
||||
Tests and tooling for this track currently support `3.7` - `3.10.6` (_tests_) and [`Python 3.11`][311-new-features] (_tooling_).
|
||||
It is highly recommended that students upgrade to at least `Python 3.8`, as some features used by this track may not be supported in earlier versions.
|
||||
That being said, most of the exercises will work with `Python 3.6+`, and many are compatible with `Python 2.7+`.
|
||||
That being said, most of the exercises will work with `Python 3.6+`.
|
||||
But we don't guarantee support for versions not listed under [Active Python Releases][active-python-releases].
|
||||
We will try to note when a feature is only available in a certain version.
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Real Python also offers a [nice guide][helpful guide] to installation on various
|
||||
Finally, these posts by Brett Cannon [A quick-and-dirty guide][quick-and-dirty] and [Why you should use `python -m pip`][python-m-pip], give very helpful advice on how to manage Python installations and packages.
|
||||
|
||||
**Note for MacOS users:** prior to MacOS Monterey (12.3), `Python 2.7` came pre-installed with the operating system.
|
||||
Using `Python 2.7` with Exercism or most other programs is not recommended.
|
||||
Using `Python 2.7` with Exercism or most other programs is not supported.
|
||||
You should instead install [Python 3][Python-three downloads] via one of the methods detailed below.
|
||||
As of MacOS Monterey (12.3), no version of Python will be pre-installed via MacOS.
|
||||
|
||||
@@ -20,7 +20,7 @@ Some quick links into the documentation by operating system:
|
||||
|
||||
Exercism tests and tooling currently support `3.7` - `3.10.6` (_tests_) and [`Python 3.11`][311-new-features] (_tooling_).
|
||||
Exceptions to this support are noted where they occur.
|
||||
Most of the exercises will work with `Python 3.6+`, and many are compatible with `Python 2.7+`.
|
||||
Most of the exercises will work with `Python 3.6+`.
|
||||
But we don't guarantee support for versions not listed under [Active Python Releases][active-python-releases].
|
||||
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ False
|
||||
Unlike numbers, strings (`str`) are compared [_lexicographically_][lexographic order], using their individual Unicode code points (_the result of passing each code point in the `str` to the built-in function [`ord()`][ord], which returns an `int`_).
|
||||
If all code points in both strings match and are _**in the same order**_, the two strings are considered equal.
|
||||
This comparison is done in a 'pair-wise' fashion - first-to-first, second-to-second, etc.
|
||||
Unlike in Python 2.x, in Python 3.x, `str` and `bytes` cannot be directly coerced/compared.
|
||||
In Python 3.x, `str` and `bytes` cannot be directly coerced/compared.
|
||||
|
||||
```python
|
||||
>>> 'Python' > 'Rust'
|
||||
|
||||
@@ -25,7 +25,7 @@ class CircularBuffer:
|
||||
self.read_point = 0
|
||||
self.write_point = 0
|
||||
|
||||
# (protected) helper method to support python 2/3
|
||||
# (protected) helper method
|
||||
def _update_buffer(self, data):
|
||||
try:
|
||||
self.buffer[self.write_point] = data
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
|
||||
{{ macros.header() }}
|
||||
|
||||
# Python 2/3 compatibility
|
||||
if not hasattr(unittest.TestCase, 'assertCountEqual'):
|
||||
unittest.TestCase.assertCountEqual = unittest.TestCase.assertItemsEqual
|
||||
|
||||
class {{ exercise | camel_case }}Test(unittest.TestCase):
|
||||
{% for case in cases -%}
|
||||
|
||||
@@ -6,10 +6,6 @@ from pythagorean_triplet import (
|
||||
|
||||
# Tests adapted from `problem-specifications//canonical-data.json`
|
||||
|
||||
# Python 2/3 compatibility
|
||||
if not hasattr(unittest.TestCase, "assertCountEqual"):
|
||||
unittest.TestCase.assertCountEqual = unittest.TestCase.assertItemsEqual
|
||||
|
||||
|
||||
class PythagoreanTripletTest(unittest.TestCase):
|
||||
def test_triplets_whose_sum_is_12(self):
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
"""
|
||||
This exercise stub and the test suite contain several enumerated constants.
|
||||
|
||||
Since Python 2 does not have the enum module, the idiomatic way to write
|
||||
enumerated constants has traditionally been a NAME assigned to an arbitrary,
|
||||
Enumerated constants can be done with a NAME assigned to an arbitrary,
|
||||
but unique value. An integer is traditionally used because it’s memory
|
||||
efficient.
|
||||
It is a common practice to export both constants and functions that work with
|
||||
|
||||
5
pylintrc
5
pylintrc
@@ -341,11 +341,6 @@ known-standard-library=
|
||||
# Force import order to recognize a module as part of a third party library.
|
||||
known-third-party=enchant, absl
|
||||
|
||||
# Analyse import fallback blocks. This can be used to support both Python 2 and
|
||||
# 3 compatible code, which means that the block might have code that exists
|
||||
# only in one or another interpreter, leading to false positives when analysed.
|
||||
analyse-fallback-blocks=no
|
||||
|
||||
|
||||
[CLASSES]
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## Example implementation
|
||||
|
||||
Modified from the existing [example.py](https://github.com/exercism/python/blob/master/exercises/rna-transcription/example.py) to remove Python 2 compatiblity noise:
|
||||
Taken from the existing [example.py](https://github.com/exercism/python/blob/main/exercises/practice/rna-transcription/.meta/example.py):
|
||||
|
||||
```python
|
||||
DNA_TO_RNA = str.maketrans("AGCT", "UCGA")
|
||||
|
||||
Reference in New Issue
Block a user