gruiick/pySpaceTrader

python (shelve module) minimal version?

Closed this issue · 3 comments

changes between python3.7 and python3.9/3.11 make load/save processing variable depending on python/shelve versions.

python3.7 (main.py):
def load_game():
""" load saved game """
global univers, planetes, captain, fname
try:
fname = sg.popup_get_file('Saved game to open',
default_extension='.db',
file_types=(('saved game(s)', '.db'),
('all files', '
.*')),
).replace('.db', '')
except AttributeError:
pass

if fname == "":
    print("empty filename!")
    load_game()
    """ ... """

python3.9/3.11 (main.py):
def load_game():
""" load saved game """
global univers, planetes, captain, fname
try:
fname = sg.popup_get_file('Saved game to open',
default_extension='.db',
file_types=(('saved game(s)', '.db'),
('all files', '
.*')),
) # .replace('.db', '')
except AttributeError:
pass

if fname == "":
    print("empty filename!")
    load_game()

if ".db" not in fname:
    fname = fname + ".db"
    """ ... """

same for save()/save_as(). Deal with it or impose a minimal version for python? (as 3.7 is already deprecated)

Just for the brain: deal with it.

import platform
print(platform.python_version())

How dumb am I?

"if int(python_version())", please.

less dumb, using:

from platform import python_version
from packaging.version import Version

then:

if Version(python_version()) >= Version('3.9'):