File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
intro/create_a_command_line_parse Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
22
3+ # * Getting arguments from the terminal in a vanilla way(no modules).
4+
5+
36# We need the sys module
47import sys
58
@@ -9,6 +12,9 @@ def user_greeting(greeting, name):
912 print (message )
1013
1114
15+ # The expression (if __name__ == '__main__':) will test if we are running the script from the terminal.
16+
17+
1218if __name__ == '__main__' :
1319 greeting = 'Hello'
1420 name = 'User'
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env/ python3
2+
3+ # * Using Argparse module to handle command line arguments
4+
5+ import argparse
6+
7+ if __name__ == '__main__' :
8+ # Create interface
9+ parser = argparse .ArgumentParser (description = 'Echo input' )
You can’t perform that action at this time.
0 commit comments