Skip to content

Should we have seperate python2 and python3 codes? #141

Description

@VikingScientist

The current state of python code:

  • Tree Traversal (python2 and unfinished python3)
  • Euclidean Algorithm (python2)
  • Bubble Sort (python3, but unlisted)
  • FFT (python2)

My question is if we really need to split the code into separate implementations for python2 and python3. It would probably be a much better design to just have a python implementation, and write it so it runs on both versions. For practical purposes this means that it is the print-statement that is going to be the most obvious problem to combine, but this very neatly fixed by including the following code at the start

from __future__ import print_function

which allows python2 to write print('Hello World'). The second most obvious difference is that the division operator / is interpreted as integer-division in python2 while always floating point division in python3. Again: we can write compatible code by including the __future__ library

from __future__ import division

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DiscussionThis is open for a discussion.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions