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


Groups > comp.lang.python > #92951

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

From Cecil Westerhof <Cecil@decebal.nl>
Newsgroups comp.lang.python
Subject Re: How to check in script if Python or Jython is used
Date 2015-06-21 12:24 +0200
Organization Decebal Computing
Message-ID <87d20p8im6.fsf@Equus.decebal.nl> (permalink)
References <87r3p5pjjd.fsf@Equus.decebal.nl> <mailman.673.1434878583.13271.python-list@python.org>

Show all headers | View raw


On Sunday 21 Jun 2015 11:22 CEST, Laura Creighton wrote:

> In a message of Sun, 21 Jun 2015 10:12:06 +0200, Cecil Westerhof
> writes:
>> 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.
>>
>> -- 
>> Cecil Westerhof
>> Senior Software Engineer
>> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
>> -- 
>> https://mail.python.org/mailman/listinfo/python-list
>
> import platform
> platform.python_implementation()
>
> If your jython is old (pre 2.6) you will not have this.
>
> Then try
> platform.system()
> which will give you 'Java'

Works like a charm. CPython gives (on my system) 'Linux'. But as long
I only work with CPython and Jython, I only have to check for 'Java'.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

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