RE: [Tutor] Of fish and foul...(aka the Perl require command)

2005-04-19 Thread Smith, Jeff
Thanks,

That does the trick.  Rather than make a function, I'm likely to just
do:

if sys.version_info[:3]  (X,Y,Z):
raise RuntimeError

Jeff

-Original Message-
From: Max Noel [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 18, 2005 3:34 PM
To: Smith, Jeff
Cc: tutor@python.org
Subject: Re: [Tutor] Of fish and foul...(aka the Perl require command)



On Apr 18, 2005, at 19:59, Smith, Jeff wrote:

 Is there a Python equivalent to the Perl

 require 5.6.0

 Which enforces a minimum interpreter version?

As far as I know, no. But:

  import sys
  sys.version_info
(2, 3, 0, 'final', 0)
  (2, 4, 0)  sys.version_info
True
  (2, 2, 0)  sys.version_info
False

So you can create one yourself quite easily.



import sys

def require(version):
 if sys.version_info  version:
 raise OSError, This program requires Python v%s or later % 
'.'.join(map(str, version))



  require((2,4,1))
Traceback (most recent call last):
   File stdin, line 1, in ?
   File stdin, line 3, in require
OSError: This program requires Python v2.4.1 or later


I'm not really sure what exception I should raise, though --
OSError 
is the most appropriate, but not exactly the Right Thing... Oh, well. 
*shrugs*

-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
Look at you hacker... A pathetic creature of meat and bone, panting 
and sweating as you run through my corridors... How can you challenge a 
perfect, immortal machine?

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Of fish and foul...(aka the Perl require command)

2005-04-18 Thread Smith, Jeff
Is there a Python equivalent to the Perl

require 5.6.0

Which enforces a minimum interpreter version?

Is there a good Python for Perl Programmers book?  It thought O'Reilly
had one but I couldn't find it.  Was this particular question in the
book you recommend?

Thanks,
Jeff
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Of fish and foul...(aka the Perl require command)

2005-04-18 Thread Bill Campbell
On Mon, Apr 18, 2005, Smith, Jeff wrote:
Is there a Python equivalent to the Perl

require 5.6.0

Which enforces a minimum interpreter version?

Is there a good Python for Perl Programmers book?  It thought O'Reilly
had one but I couldn't find it.  Was this particular question in the
book you recommend?

Good?  That depends on what your standards are.  I found ``Perl
to Python Migration'' by Martin C. Brown useful.  I think I found
this on bookpool.com, but you can always try bookfinder.com which
can find pretty much anything.

Bill
--
INTERNET:   [EMAIL PROTECTED]  Bill Campbell; Celestial Software LLC
UUCP:   camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:(206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

``Are we at last brought to such a humiliating and debasing degradation,
that we cannot be trusted with arms for our own defense? Where is the
difference between having our arms in our own possession and under our own
direction, and having them under the management of Congress? If our defense
be the real object of having those arms, in whose hands can they be trusted
with more propriety, or equal safety to us, as in our own hands?''
-- Patrick Henry June 9, 1788, in the Virginia Convention on the
ratification of the Constitution.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Of fish and foul...(aka the Perl require command)

2005-04-18 Thread Max Noel
On Apr 18, 2005, at 19:59, Smith, Jeff wrote:
Is there a Python equivalent to the Perl
require 5.6.0
Which enforces a minimum interpreter version?
As far as I know, no. But:
 import sys
 sys.version_info
(2, 3, 0, 'final', 0)
 (2, 4, 0)  sys.version_info
True
 (2, 2, 0)  sys.version_info
False
So you can create one yourself quite easily.

import sys
def require(version):
if sys.version_info  version:
raise OSError, This program requires Python v%s or later % 
'.'.join(map(str, version))


 require((2,4,1))
Traceback (most recent call last):
  File stdin, line 1, in ?
  File stdin, line 3, in require
OSError: This program requires Python v2.4.1 or later
	I'm not really sure what exception I should raise, though -- OSError 
is the most appropriate, but not exactly the Right Thing... Oh, well. 
*shrugs*

-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
Look at you hacker... A pathetic creature of meat and bone, panting 
and sweating as you run through my corridors... How can you challenge a 
perfect, immortal machine?

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor