Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shebang line to default template.py #3029

Merged
merged 2 commits into from
Mar 13, 2016
Merged

Conversation

Nodd
Copy link
Contributor

@Nodd Nodd commented Mar 4, 2016

It makes it easier to run scripts outside of spyder on linux.

The template could be further enhanced (add if __name__ == "__main__" for example).

@@ -382,8 +382,10 @@ def __init__(self, parent, ignore_last_opened_files=False):

# Creating template if it doesn't already exist
if not osp.isfile(self.TEMPLATE_PATH):
header = ['# -*- coding: utf-8 -*-', '"""', 'Created on %(date)s',
'', '@author: %(username)s', '"""', '']
header = ['#!/usr/bin/env python' + ('2' if PY2 else '3'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be here only if we are not on Windows, i.e. if not os.name == 'nt'

@ccordoba12
Copy link
Member

if __name__ == "__main__" is not for everybody and every situation, so I don't think we should include it.

@ccordoba12 ccordoba12 modified the milestones: v3.0beta4, v3.0beta3 Mar 5, 2016
@Nodd
Copy link
Contributor Author

Nodd commented Mar 8, 2016

The shebang shouldn't appear on windows now.
I agree about if __name__ == "__main__". When #2884 is implemented it will be easily changed by the user.

@ccordoba12 ccordoba12 modified the milestones: v3.0beta3, v3.0beta4 Mar 13, 2016
ccordoba12 added a commit that referenced this pull request Mar 13, 2016
Add shebang line to default template.py
@ccordoba12 ccordoba12 merged commit 515c229 into spyder-ide:master Mar 13, 2016
@mdraw
Copy link

mdraw commented Mar 22, 2016

The shebang shouldn't appear on windows now.

@Nodd Why would you leave out the shebang on Windows? The shebang line is also interpreted on Windows, see https://docs.python.org/3/using/windows.html#shebang-lines and https://www.python.org/dev/peps/pep-0397/.

@Nodd
Copy link
Contributor Author

Nodd commented Mar 23, 2016

@mdraw I left it out because the boss (@ccordoba12) said so ! But since it's interpreted, I'll add it again.

@Nodd Nodd self-assigned this Mar 23, 2016
@ccordoba12
Copy link
Member

I'm -1 on adding a shebang to Windows scripts because:

  1. It only works in Python 3.
  2. It could confuse Windows users if it comes as /usr/bin/env python. I mean, it would (most probably) make them believe that that's an error or something. Experienced users (like @mdraw) can easily add the shebang themselves :-)

@Nodd
Copy link
Contributor Author

Nodd commented Mar 24, 2016

I have some counter arguments, but since it's a detail and it's so easy to change I think it's not worth the time. I'll left it as is.

@Nodd Nodd deleted the shebang branch March 24, 2016 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants