Is it possible to check python version from restricted python?
In 'normal view', I could do something like:
if six.PY3:
something
else:
somethingelse
Is it possible to check python version from restricted python?
In 'normal view', I could do something like:
if six.PY3:
something
else:
somethingelse
Maybe you can have some luck with something like:
try:
unicode
somethingelse
except NameError:
something
or:
if isinstance(u"", str):
something
else:
somethingelse
You could make a view that will return the python version and check that.
One question remains: why do you need this? There might be a better route to solving your problem.
I have some themingfragments that are both used on 5.2 with Python3.
With python 3 I can do
keyword = data['keyword']
return self.context.portal_catalog(Subject=keyword, etc)
while on 'the old', I need to do
keyword.encode('ascii') (or something similar)
In 'normal python', all my checks for encoding etc is done with six, but in restricted python I can not import six
That seems to work, and probably adresses my problem 'better than my python check'.
Thanks