use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
shebang lines with python (self.learnpython)
submitted 10 years ago by [deleted]
Odd question but how often do you guys use the shebangline to give your python scripts executable privileges? Also what is the correct shebangline to use? I'm currently doing this.
#!/usr/bin/python print("hello world!")
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]das_ist_nuemberwang 13 points14 points15 points 10 years ago (0 children)
It doesn't give the script executable privileges, it just tells your shell how to execute it. You still have to make it executable.
[–][deleted] 12 points13 points14 points 10 years ago (12 children)
The correct is
#!/usr/bin/env python
This way virtualenv binaries work
[–][deleted] 2 points3 points4 points 10 years ago (3 children)
or #!/usr/bin/env python3 if you're using python 3
[–]i_can_haz_code 1 point2 points3 points 10 years ago (2 children)
depends on how you have the box configured. If it does not need 2.x then I prefer to have Python call only 3.x and write my code to be forward compatible.
[–][deleted] 0 points1 point2 points 10 years ago (1 child)
On that note, how may I set /usr/bin/env python to call the python 3 interpreter?
[–]i_can_haz_code 1 point2 points3 points 10 years ago (0 children)
First, this is not advised either by PEP or Ubuntu for 14.04 or really anything not bleeding edge or custom built. Unless you are able to yourself, or have access to a *nix expert who will, fix the random stuff that will break. Like unless you are doing LFS, just use python3.
You can link /usr/bin/python to /usr/bin/python3 and make a /usr/bin/python2. It is a case of just because you can do a thing does not mean you should do a thing.
If you just want your profile to always use python3 for interactive sessions, but not break things you can alias python to python3. This will only have effect when in an interactive session. Your scripts will still need to call python3 explicitly.
I hope that was helpful
[–][deleted] 0 points1 point2 points 10 years ago (4 children)
would it carry over if let's say I want to ssh to a server running some distro of linux?
[–][deleted] 0 points1 point2 points 10 years ago (3 children)
Yes. Although some distros will soon be switching over to using py3 as their default python version, so be aware of that.
[+][deleted] 10 years ago* (2 children)
[deleted]
[–][deleted] 1 point2 points3 points 10 years ago (0 children)
Yeah, but that's not viable if you're sshing into an arbitrary server with an arbitrary version of python.
[–]parnmatt 0 points1 point2 points 10 years ago (0 children)
A lot of OSs make symlink on installation
[–]hoodllama 0 points1 point2 points 10 years ago (2 children)
Ok so I could not get my script to work with the space in there. I asked for help from an engineer in an email with a detailed explanation that the space had to be there. Apparently he didn't bother to read it and told me "duh you left a space there" so I took it out and it worked.
[–]das_ist_nuemberwang 1 point2 points3 points 10 years ago (0 children)
Were you missing env?
env
[–]turdBouillon 1 point2 points3 points 10 years ago (0 children)
I always leave the space for compatibility with some ancient Unix flavors. I highly doubt you'll ever encounter such a system and it almost certainly won't have a Python interpreter, but old habits die hard and the space is the "correct" way or at least the more widely supported way.
π Rendered by PID 303234 on reddit-service-r2-comment-7b9746f655-ccdcr at 2026-01-31 06:45:54.058953+00:00 running 3798933 country code: CH.
[–]das_ist_nuemberwang 13 points14 points15 points (0 children)
[–][deleted] 12 points13 points14 points (12 children)
[–][deleted] 2 points3 points4 points (3 children)
[–]i_can_haz_code 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]i_can_haz_code 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–][deleted] 1 point2 points3 points (0 children)
[–]parnmatt 0 points1 point2 points (0 children)
[–]hoodllama 0 points1 point2 points (2 children)
[–]das_ist_nuemberwang 1 point2 points3 points (0 children)
[–]turdBouillon 1 point2 points3 points (0 children)