Skip to content

Commit

Permalink
Remove Python 2 references from the track (#3437)
Browse files Browse the repository at this point in the history
* Remove Python 2 references from the track

* Revert unintentional whitespace changes to test files

[no important files changed]
  • Loading branch information
IsaacG authored Jul 14, 2023
1 parent 5bb5959 commit 29a64a4
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion concepts/comparisons/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion concepts/string-formatting/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_.

Expand Down
2 changes: 1 addition & 1 deletion docs/ABOUT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions docs/INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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].


Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/black-jack/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/circular-buffer/.meta/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, capacity):
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
Expand Down
3 changes: 0 additions & 3 deletions exercises/practice/pythagorean-triplet/.meta/template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

# 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):
Expand Down
3 changes: 1 addition & 2 deletions exercises/practice/sublist/sublist.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 0 additions & 5 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion reference/exercise-concepts/rna-transcription.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 29a64a4

Please sign in to comment.