Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.python Subject: Re: How to check in script if Python or Jython is used Date: Sun, 21 Jun 2015 12:24:01 +0200 Organization: Decebal Computing Lines: 33 Message-ID: <87d20p8im6.fsf@Equus.decebal.nl> References: <87r3p5pjjd.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="528adfd6ad074c92fdc6a7f8fb9e23d8"; logging-data="8365"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18FweLjiglbYjKq4BpbRbwlwrh3/uUEOP4=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Homepage: http://www.decebal.nl/ Cancel-Lock: sha1:FoQI1+c3YQO9x3oiwBB9vzCXCb8= sha1:SO/OKKhdaUhSQ0mNvHf8gYKDhic= Xref: csiph.com comp.lang.python:92951 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