4

I wrote my code in the python 3.7 interpreter in pycharm, but I don't know how can I verify it can be interpreted by 3.6x?

ShadowRanger
  • 143,180
  • 12
  • 188
  • 271
Tsubaki
  • 61
  • 5

2 Answers2

6

Write good tests and run them in 3.6. There is no automated way to confirm some change in the language wasn't introduced in 3.7. You can read the What's New in Python 3.7 page to try to make sure you're not using a new in 3.7 feature/behavior that didn't exist in 3.6, but there is no 100% automated solution here; you'll have to write the tests yourself.

ShadowRanger
  • 143,180
  • 12
  • 188
  • 271
  • 2
    I'll add that [tox](https://tox.readthedocs.io/) is a great tool for running your tests with multiple Python interpreters. – Daniel Pryden Mar 15 '19 at 23:26
  • can ipython notebook confirm that too? – Tsubaki Mar 16 '19 at 01:19
  • @Tsubaki: I have no idea what you mean by that. ipython notebook is just a way of running Python code. It can be installed over different versions of Python. If it's based on 3.6, it will run 3.6 compatible code; base it on 3.7, it'll run 3.7 compatible code. – ShadowRanger Mar 16 '19 at 01:22
0

You can try changing your project's interpreter then running your code on different versions.

You'll have to install both 3.6 and 3.7 on your env first, though.
Then select which interpreter to use from Pycharm.

Note: I don't have Python3.6 on my env but it's the same idea. select Python interpreter

For more info on adding and configuring different interpreters, see the Configuring Python Interpreter docs from Jetbrains.

In PyCharm you are not limited to using just any single Python interpreter. You are able to implement several and in doing so choose which interpreter you wish to use for any specific project.

PyCharm supports:

  • Standard Python interpreters (see the Supported versions)
  • Other Python implementations (IronPython, PyPy, Jython, CPython)
  • Virtualenv Environments: Virtualenv, Pipenv, and Conda.
  • Remote Python interpreters ( SSH, Vagrant, WSL (only for Windows)).
    Supported only in PyCharm Professional.
  • Docker-based interpreters (Docker, Docker Compose).
    Supported only in PyCharm Professional.

See also this related SO post on How to select Python version in PyCharm?.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135