pycharm - Python convention for specifying compatible interpreter versions? -


similarly __author__ or __version__ top level module variables, there convention specifying supported python versions python source file?

my usecase project has scripts need compatible python 2.4. note fact in them in universally recognizable way.

i not asking how require minimal python version during execution. problem developers may accidentally use feature not compatible python version particular script needs support. pycharm can warn python incompatibilities. great if pick annotation , configure warning on per-file basis.

there's no convention know of specifying supported python versions in python source file. if you're making python library , distributing via pypi (and pip), can add package metadata says versions of python it's compatible with.

for example, scandir module, can see on pypi it's (currently) marked compatible python 2.6, 2.7, , 3.2-3.5. metadata lives in classifiers keyword in package's setup.py:

setup(     name='scandir',     # ...     classifiers=[         'programming language :: python :: 2',         'programming language :: python :: 2.6',         'programming language :: python :: 2.7',         'programming language :: python :: 3',         'programming language :: python :: 3.2',         'programming language :: python :: 3.3',         'programming language :: python :: 3.4',         'programming language :: python :: 3.5',         # ...     ] ) 

if you're not releasing pypi package, 1 alternative might produce warning when module imported on older version of python, saying fizzbuzz feature isn't supported on version of python.

import sys, warnings if sys.version_info < (3, 5):     warnings.warn('the fizzbuzz feature supported on python 3.5+') 

all said, i'd keep simple: document feature x supported on python 3.5+ , if tries use feature on older version, let fail.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -