Re: Obtaining Python version

2009-08-04 Thread Xavier Ho
On Wed, Aug 5, 2009 at 12:44 AM, D'Arcy J.M. Cain wrote: > On Wed, 5 Aug 2009 00:39:56 +1000 >> Xavier Ho wrote: >> > So, what am I doing wrong here? >> > >> > >>> int(str(0x00F0), 16) >> >> Look at the output of str(0x00F0) for a clue. >> > > ... Wow. I *am* slow tonight. Thanks. > > >>> int('0

Re: Obtaining Python version

2009-08-04 Thread D'Arcy J.M. Cain
On Wed, 5 Aug 2009 00:39:56 +1000 Xavier Ho wrote: > So, what am I doing wrong here? > > >>> int(str(0x00F0), 16) Look at the output of str(0x00F0) for a clue. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 4

Re: Obtaining Python version

2009-08-04 Thread Xavier Ho
On Wed, Aug 5, 2009 at 12:17 AM, MRAB wrote: > 0x00F0 is 240. ... Right. I wonder where my brain is. *searches pocket* So, what am I doing wrong here? >>> int(str(0x00F0), 16) 576 Cheers, -Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Obtaining Python version

2009-08-04 Thread MRAB
Xavier Ho wrote: On Tue, Aug 4, 2009 at 9:34 PM, Xavier Ho > wrote: ... and '00F0' is r31! Actually, 00F0 is 576 in decimal. Maybe it's the subversion? 0x00F0 is 240. Anyhow, it's still good! -- http://mail.python.org/mailman/listinfo/python-list

Re: Obtaining Python version

2009-08-04 Thread Xavier Ho
On Tue, Aug 4, 2009 at 9:34 PM, Xavier Ho wrote: > ... and '00F0' is r31! > Actually, 00F0 is 576 in decimal. Maybe it's the subversion? Anyhow, it's still good! -- http://mail.python.org/mailman/listinfo/python-list

Re: Obtaining Python version

2009-08-04 Thread Xavier Ho
On Tue, Aug 4, 2009 at 8:30 PM, Yinon Ehrlich wrote: > Hi, > Easy way to test for Python version: > if sys.hexversion >= 0x2060100: > pass > Great suggestion. I just tested it on my newly installed Python 3.1 (as of 3.1r31) >>> import sys >>> "%X" % sys.hexversion '30100F0' That's genius - '3

Re: Obtaining Python version

2009-08-04 Thread Yinon Ehrlich
On Aug 4, 1:19 am, John Nagle wrote: > This works, but it seems too cute: > >  >>> pyver = map(int,sys.version.split()[0].split('.')) >  >>> print(pyver) > [2, 6, 1] > > Is it guaranteed that the Python version string will be in a form > suitable for that?  In other words, does "sys.version" begin

Re: Obtaining Python version

2009-08-03 Thread Jan Kaliszewski
04-08-2009 o 00:19:22 John Nagle wrote: This works, but it seems too cute: >>> pyver = map(int,sys.version.split()[0].split('.')) >>> print(pyver) [2, 6, 1] Is it guaranteed that the Python version string will be in a form suitable for that? In other words, does "sys.version" begin N.N.N

Re: Obtaining Python version

2009-08-03 Thread André
On Aug 3, 7:19 pm, John Nagle wrote: > This works, but it seems too cute: > >  >>> pyver = map(int,sys.version.split()[0].split('.')) >  >>> print(pyver) > [2, 6, 1] > You can also do: >>> import sys >>> sys.version_info (2, 5, 2, 'final', 0) or >>> sys.version_info[:3] (2, 5, 2) > Is it guara

Obtaining Python version

2009-08-03 Thread John Nagle
This works, but it seems too cute: >>> pyver = map(int,sys.version.split()[0].split('.')) >>> print(pyver) [2, 6, 1] Is it guaranteed that the Python version string will be in a form suitable for that? In other words, does "sys.version" begin N.N.N other stuff in all versions, and will it sta