diff options
author | Santosh G. Vattam | 2010-05-11 08:27:24 +0530 |
---|---|---|
committer | Santosh G. Vattam | 2010-05-11 08:27:24 +0530 |
commit | b4a6ef0ac9b27d040c97bc6eb5bd99ed56246373 (patch) | |
tree | e99c1c68437827790992e511d7344f50191ceb19 | |
parent | 6bb546958c755dfe7f5301213764c441ccd1f991 (diff) | |
download | st-scripts-b4a6ef0ac9b27d040c97bc6eb5bd99ed56246373.tar.gz st-scripts-b4a6ef0ac9b27d040c97bc6eb5bd99ed56246373.tar.bz2 st-scripts-b4a6ef0ac9b27d040c97bc6eb5bd99ed56246373.zip |
Minor edits to functions.org.
-rw-r--r-- | functions.org | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/functions.org b/functions.org index 5675cc3..bb49268 100644 --- a/functions.org +++ b/functions.org @@ -22,17 +22,19 @@ equations. We shall first review these basics. Then we shall move on to other details such as doc-strings, default arguments and keyword arguments. + + First let's start IPython by typing ipython in the terminal. - Let's write a simple function that prints a Hello message, after + Let's write a simple function that prints a Hello message, upon accepting a name. def welcome(name): print "Hello", name - You would recall that def is a keyword that indicates a function + You would recall that def is a keyword that indicates the function definition. 'welcome' is the name of the function and 'name' is the lone argument to the function. Note that the function is - defined within an indented block, similar to any other block. Our + defined within an indented block, just like to any other block. Our function welcome just has one line in it's definition. We can call our function, as follows - @@ -55,7 +57,10 @@ Notice that the doc string uses triple quotes. If the doc-string exceeds one line, we can use new line characters in it. Also, as expected the doc-string is indented as is required - for anything within a block. + for anything within a block. Now that we have written the + documentation, how do we access it? IPython provides the question + mark feature that we have seen in the previous tutorials. welcome? + will display the docstring that we have just written. We shall now look at default arguments. [show slide with examples of functions with default arguments] |