Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

python parameters in teamtreehouse?

how do I pass parameters to python?

Kenneth Love any course on this?

3 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Well, there's the built-in argparse which works but is kind of unwieldy. I like the click library, myself.

If you are speaking in reference to functions then you would do something like this:

def addition(num1, num2): # <----- This function will require 2 parameters to be passed to it(num1 and num2)
    sum = num1 + num2
    print(sum)

# call the function like this

addition(5, 6) # <--- The 5 and 6 are the parameters being passed to the function 'addition'

Im talking about passing parameters in command line...sorry for not clarifying

I was thinking you might have been referencing command line, but I didn't want to jump to a more advanced conclusion. Here is some pretty good documentation regarding command line arguments.

http://www.tutorialspoint.com/python/python_command_line_arguments.htm