Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: how to get python version ? Date: Thu, 28 Jan 2016 16:34:12 +1100 Lines: 36 Message-ID: References: <76180516-f465-4fde-a1c4-920c91036623@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de 53rDcEWZD6F3YLqXD5NFEAvhpeY3DE8TDKRt/ut2NYsw== Cancel-Lock: sha1:F4PlZ1hKA+Q5lGyNZSWzoQB5zDE= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'string.': 0.04; 'sys': 0.05; 'sys.platform': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:version': 0.09; 'python': 0.10; 'jan': 0.11; 'subject:python': 0.14; '(2,': 0.16; '(3,': 0.16; 'comparisons,': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'structure.': 0.16; '>>>': 0.20; 'import': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'subject: ?': 0.27; 'question': 0.27; 'somebody': 0.30; "can't": 0.32; 'point': 0.33; 'url:python': 0.33; '8bit%:25': 0.33; 'lets': 0.33; 'running': 0.34; 'false': 0.35; 'something': 0.35; 'too': 0.36; 'there': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'received:org': 0.37; 'version': 0.38; 'to:addr:python.org': 0.40; 'url:3': 0.60; 'email addr:gmail.com': 0.62; 'more': 0.63; 'skip:\xe2 10': 0.70; '8bit%:27': 0.72; 'subject:get': 0.81; '5.3.1': 0.84; '_o__)': 0.84; 'amis': 0.84; 'received:125': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102171 namenobodywants@gmail.com writes: > is there something analogous to sys.platform that lets you get the > version of python you're using? sorry if the question is too > see-spot-run. thanks if you can help The same ‘sys’ module provides many other ways to interrogate the running Python system . For the running version of Python, you want ‘sys.version_info’:: >>> import sys >>> sys.version '2.7.11 (default, Jan 11 2016, 21:04:40) \n[GCC 5.3.1 20160101]' >>> type(sys.version) >>> sys.version_info sys.version_info(major=2, minor=7, micro=11, releaselevel='final', serial=0) >>> type(sys.version_info) >>> sys.version_info > (3, 1) False >>> sys.version_info > (2, 5) True The ‘sys.version’ object is a human-readable string. If you actually want to do comparisons, use ‘sys.version_info’ for its much more fine-grained structure. -- \ “If you can't annoy somebody there is little point in writing.” | `\ —Kingsley Amis | _o__) | Ben Finney