Python practice: handling command-line arguments (with sys.argv module)

#! usr/bin/env python3
# by lorenzo - 27/09/2017
# handling command-line arguments with sys.argv (practice)
# the script prints to the screen whatever command-line arguments one gives it;
# running the script in the shell with the command:
# python3 commandLine.py hello, world!
# returns: hello, world!

import sys

if len(sys.argv) > 1:
    print(' '.join(sys.argv[1:]))

Comments about the code are welcome.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s