[Tutor] Feature or ... after python 2.7

Alan Gauld alan.gauld at yahoo.co.uk
Wed Jan 25 04:03:24 EST 2017


On 25/01/17 02:55, source liu wrote:

> 2.7. (2.7.16 if I remembered it correctly),  one could run python script
> with perl
> 
> $cat test.py
> #!/bin/env python
> print "I am python"
> 
> 
> $perl test.py
> I am python
> 

That is just because this particular print statement
is compatible with Perl. If you had tried anything
more complex then it would have bombed.

> But it would fail if you tried to use python2.6(which go with rhel6.8)

I'm not sure what you mean here but you could run the
code above in any version of Python v2 or perl and
it should work. The first6 line is a comment so
ignored by both perl and python. And the print
statement works in both languages.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list