Skip to content

Instantly share code, notes, and snippets.

@davidnuon
Last active July 19, 2016 17:57
Show Gist options
  • Save davidnuon/ca82207972f2e45717406712ae0881ed to your computer and use it in GitHub Desktop.
Save davidnuon/ca82207972f2e45717406712ae0881ed to your computer and use it in GitHub Desktop.
Shebangs in Action
#!/usr/bin/env python
import sys
print('Arguments')
print(sys.argv)
print('File content')
with open(sys.argv[-1]) as f:
print f.read()
$ ./script
Arguments
['/home/davidnuon/davidbasic/basic', './script']
File content
#!/home/davidnuon/davidbasic/basic
# ^ There can be anywhere
Here is my thing
WOLOLO
#!/home/davidnuon/davidbasic/basic
# ^ There can be anywhere
Here is my thing
WOLOLO
@thebeachdev
Copy link

thebeachdev commented Jul 19, 2016

Interesting. On line 4 of output its it calling script as a variable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment