From the course: Intermediate Python for Non-Programmers
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Command-line arguments - Python Tutorial
From the course: Intermediate Python for Non-Programmers
Command-line arguments
- [Instructor] Well, welcome to your last section where you're going to be learning new skills. Now we still have a section after this where we have a project where we're going to put everything together but you're getting so close to the end. Hopefully you've been enjoying learning so far. Let's now talk about arguments. So whenever we run a Python script or program inside of a terminal, we have the option to pass some more information into it and I'm going to show you how that works here. Now, something will be interesting about this video. You'll find, we'll actually do most of the learning in the challenge, so just stay with me and you'll see how that goes. So to start with, we first need to import sys. So this is a library that allows us to work with system level things. And with this sys, we get access to sys.argv which is just all the arguments that are passed into the script. So to simply see what arguments there are, we're going to say for argument in sys.argv, do a colon so…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.