Re: [Tutor] Checking for Python version

2009-10-08 Thread Kent Johnson
On Tue, Oct 6, 2009 at 9:59 AM, Didar Hossain wrote: > Hi, > > I am using the following code to check for the Python version - > > import os > > t = os.sys.version_info[0:2] > if (t[0] + t[1]) < 6: Hmm, what would this give for Python 1.5? How about if t < (2, 4): >    os.sys.exit("Need at least

Re: [Tutor] Checking for Python version

2009-10-07 Thread Didar Hossain
I like Kent's "try" method to explicitly look for the "staticmethod" call - it is Pythony :-) Todd's graceful handling idea is a good one - will keep that for future use. Christian's input about my kludge failing with the 3.x series is a good catch, I didn't think about that. Thanks to all of yo

Re: [Tutor] Checking for Python version

2009-10-06 Thread Luke Paireepinart
On Tue, Oct 6, 2009 at 4:47 PM, Wayne wrote: > > On Tue, Oct 6, 2009 at 9:46 AM, Steve Willoughby wrote: > >> On Tue, Oct 06, 2009 at 09:42:04AM -0500, Wayne wrote: >> > On Tue, Oct 6, 2009 at 9:26 AM, Christian Witts > >wrote: >> > if sys.version < '2.4': >> >sys.exit("Need at least Python 2

Re: [Tutor] Checking for Python version

2009-10-06 Thread Christian Witts
Todd Zullinger wrote: Christian Witts wrote: Your version will fail if the person is running Python 3.0, 3.1 up until the 3.3 series which is not good. Neater looking (imo) code below. from sys import version_info, exit if version_info[0] == 1 or (version_info[0] == 2 and version_info[1] <

Re: [Tutor] Checking for Python version

2009-10-06 Thread Dave Angel
Didar Hossain wrote: Hi, I am using the following code to check for the Python version - import os t = os.sys.version_info[0:2] if (t[0] + t[1]) < 6: os.sys.exit("Need at least Python 2.4") del t This snippet is put at the beginning of the single script file before the rest of the code. I

Re: [Tutor] Checking for Python version

2009-10-06 Thread Wayne
On Tue, Oct 6, 2009 at 9:57 AM, Steve Willoughby wrote: > On Tue, Oct 06, 2009 at 09:47:43AM -0500, Wayne wrote: > > On Tue, Oct 6, 2009 at 9:46 AM, Steve Willoughby > wrote: > > > > > On Tue, Oct 06, 2009 at 09:42:04AM -0500, Wayne wrote: > > > > On Tue, Oct 6, 2009 at 9:26 AM, Christian Witts

Re: [Tutor] Checking for Python version

2009-10-06 Thread Todd Zullinger
Christian Witts wrote: > Your version will fail if the person is running Python 3.0, 3.1 up > until the 3.3 series which is not good. Neater looking (imo) code > below. > > from sys import version_info, exit > > if version_info[0] == 1 or (version_info[0] == 2 and version_info[1] < 4): >exit("

Re: [Tutor] Checking for Python version

2009-10-06 Thread Steve Willoughby
On Tue, Oct 06, 2009 at 09:47:43AM -0500, Wayne wrote: > On Tue, Oct 6, 2009 at 9:46 AM, Steve Willoughby wrote: > > > On Tue, Oct 06, 2009 at 09:42:04AM -0500, Wayne wrote: > > > On Tue, Oct 6, 2009 at 9:26 AM, Christian Witts > >wrote: > > > if sys.version < '2.4': > > >sys.exit("Need at l

Re: [Tutor] Checking for Python version

2009-10-06 Thread Wayne
On Tue, Oct 6, 2009 at 9:46 AM, Steve Willoughby wrote: > On Tue, Oct 06, 2009 at 09:42:04AM -0500, Wayne wrote: > > On Tue, Oct 6, 2009 at 9:26 AM, Christian Witts >wrote: > > if sys.version < '2.4': > >sys.exit("Need at least Python 2.4") > > > > AFAIK the string comparison is reliable > >

Re: [Tutor] Checking for Python version

2009-10-06 Thread Steve Willoughby
On Tue, Oct 06, 2009 at 09:42:04AM -0500, Wayne wrote: > On Tue, Oct 6, 2009 at 9:26 AM, Christian Witts wrote: > if sys.version < '2.4': >sys.exit("Need at least Python 2.4") > > AFAIK the string comparison is reliable Not quite. What happens when you compare '2.4' and '2.10'? -- Steve Wi

Re: [Tutor] Checking for Python version

2009-10-06 Thread Wayne
On Tue, Oct 6, 2009 at 9:26 AM, Christian Witts wrote: > Didar Hossain wrote: > >> Hi, >> >> I am using the following code to check for the Python version - >> >> import os >> >> t = os.sys.version_info[0:2] >> if (t[0] + t[1]) < 6: >>os.sys.exit("Need at least Python 2.4") >> del t >> >> This

Re: [Tutor] Checking for Python version

2009-10-06 Thread Christian Witts
Didar Hossain wrote: Hi, I am using the following code to check for the Python version - import os t = os.sys.version_info[0:2] if (t[0] + t[1]) < 6: os.sys.exit("Need at least Python 2.4") del t This snippet is put at the beginning of the single script file before the rest of the code. I

[Tutor] Checking for Python version

2009-10-06 Thread Didar Hossain
Hi, I am using the following code to check for the Python version - import os t = os.sys.version_info[0:2] if (t[0] + t[1]) < 6: os.sys.exit("Need at least Python 2.4") del t This snippet is put at the beginning of the single script file before the rest of the code. I need to check for the