Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #92968

Re: How to check in script if Python or Jython is used

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.python
Subject Re: How to check in script if Python or Jython is used
Date Sun, 21 Jun 2015 18:12:52 +0200
Organization PointedEars Software (PES)
Lines 37
Message-ID <2671202.GDDaZ1Saa3@PointedEars.de> (permalink)
References <87r3p5pjjd.fsf@Equus.decebal.nl>
Reply-To Thomas 'PointedEars' Lahn <usenet@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1434903355 13511 eJwNyskBwCAIBMCWgOVKOa5K/yWYeU8gNXd5RnpMjK6rqFbS2qyHG8x1pkRsCAE2mt9x5t8vHxvKEU8= (21 Jun 2015 16:15:55 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Sun, 21 Jun 2015 16:15:55 +0000 (UTC)
User-Agent KNode/4.14.2
X-User-ID eJwFwQkBwDAIA0BLLZDQyeH1L2F3UF6WG0HDYlvGRAyu90wFV5mD9KHvY6PYG6XdGa7+Hdt4YQBFz8tbP13nFcI=
Cancel-Lock sha1:rxs2mOqVRgODuiHxWldDWfz9lnQ=
X-NNTP-Posting-Host eJwFwYEBwCAIA7CXQGnLzgGm/59ggk3nKAgGLi6hjBDQ3D98RbU5LMtW2mg8efKcj+UyTT/1ERAQ
Xref csiph.com comp.lang.python:92968

Show key headers only | View raw


Cecil Westerhof wrote:

> I installed Jython and will start playing with it. There probably will
> be differences between Python and Jython. Is there a way to determine
> if a script is run by Python or Jython? Then different execution paths
> could be taken. With sys.version(_info) you do not get this
> information.

“print sys.__doc__” in (C)python(2) hinted at “sys.platform”.  And so:

$ python -V
Python 2.7.10

$ python -c 'from sys import platform; print platform'
linux2

$ python3 -V
Python 3.4.3+

$ python3 -c 'from sys import platform; print(platform)'
linux

$ jython -V
"my" variable $jythonHome masks earlier declaration in same scope at 
/usr/bin/jython line 15.
Jython 2.5.3

$ jython -c 'from sys import platform; print platform'
"my" variable $jythonHome masks earlier declaration in same scope at 
/usr/bin/jython line 15.
java1.7.0_79

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to check in script if Python or Jython is used Cecil Westerhof <Cecil@decebal.nl> - 2015-06-21 10:12 +0200
  Re: How to check in script if Python or Jython is used Laura Creighton <lac@openend.se> - 2015-06-21 11:22 +0200
    Re: How to check in script if Python or Jython is used Cecil Westerhof <Cecil@decebal.nl> - 2015-06-21 12:24 +0200
  Re: How to check in script if Python or Jython is used Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-21 18:12 +0200
  Re: How to check in script if Python or Jython is used Dan Stromberg <drsalists@gmail.com> - 2015-06-22 12:39 -0700

csiph-web