0

I am new to python. I have installed both version python 3.3.2 and 2.7.5 (Windows 7)

python 3.3 directory : c:\python33

python 2.7 directory : c:\python27

python33 was installed first.

What will be first line of code for both version of python? like as #! /user/bin/python ??? more importantly why this line is important ?

pepr
  • 18,012
  • 11
  • 66
  • 122
Hardik
  • 305
  • 2
  • 5
  • 12
  • See http://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script – alecxe Sep 15 '13 at 19:55
  • 1
    @Hardik -- note that since you're using Windows, the "shebang" will make no difference whatsoever. You can safely omit the line if you plan on running your script only on Windows computers. Besides the "shebang", there is no special line that _must_ go at the start. – Michael0x2a Sep 15 '13 at 20:03
  • As the question is window specific, this is definitely not a duplicate (or at least not with respect to the links). Python 3.3 for Windows introduced *Python Launcher for Windows* and the lines `#!python3` or `#!python2` make a big difference -- see the doc http://www.python.org/dev/peps/pep-0397/. Python launcher is associated with the `.py` and `.pyw` extensions and the first line helps to decide what version of Python interpreter should be used for the script. Again, **this is for Windows**. In Unix, the line purpose is more general. – pepr Sep 15 '13 at 20:47
  • @Wooble, tripleee, Sean Vieira, Ashwini Chaudhary, Michael Foukarakis -- please revoke the **duplicate**. It is Windows specific, rather new feature, and it has nothing to do with UNIX hashbang. – pepr Sep 16 '13 at 10:26

1 Answers1

3

You might want to view the following resources,

The standard first few lines is,

#!/usr/bin/python
# -*- coding: utf-8 -*-

Or whatever encoding ^^

Community
  • 1
  • 1
  • This is true for Unix. For Windows, the first line should be or `#!python2` or `#!python3` in the simplest case. – pepr Sep 16 '13 at 20:35