Skip to content

Commit 350c540

Browse files
committed
warn about mistakes
1 parent 1dc9bd0 commit 350c540

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

using-functions.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ Functions are easy to understand, They simply **do something when they
5151
are called**. Functions run immediately when we call them, so the
5252
text appears on the screen right away when we run `print(something)`.
5353

54+
Sometimes people think that doing `thingy = print('hello')` means that
55+
Python is going to print hello every time we type `thingy`. But **this
56+
is not correct**! `print('hello')` runs print right away, and if we
57+
type `thingy` later it's not going to run `print('hello')` again.
58+
5459
## Return values
5560

56-
If we do `thingy = print('hello')`, what does the `thingy` variable end
57-
up [pointing to](variables.md#variables)?
61+
Now we know that `thingy = print('hello')` doesn't store the
62+
`print('hello')` call in a variable. But what does it do then?
5863

5964
```py
6065
>>> thingy = print('hello')
@@ -64,10 +69,12 @@ None
6469
>>>
6570
```
6671

67-
So doing `thingy = print('hello')` set `thingy` to None. Here's what
68-
happened, explained in more detail:
72+
So doing `thingy = print('hello')` set `thingy` to None.
73+
74+
Here's what happened, explained in more detail:
6975

70-
- In `thingy = print('hello')`, the right side is processed first.
76+
- When we do `thingy = print('hello')`, the right side is processed
77+
first.
7178
- `print('hello')` calls the print function with the argument
7279
`'hello'`.
7380
- The function runs. It shows the word hello.
@@ -79,8 +86,9 @@ happened, explained in more detail:
7986
there, and the assignment now looks like `thingy = None`.
8087
- `thingy` is now None.
8188

82-
Now we understand what a return value is. When we call the function,
83-
Python "replaces" `function(args)` with whatever the function returns.
89+
Now we understand what **a return value** is. When we call the
90+
function, Python "replaces" `function(arguments)` with whatever the
91+
function returns.
8492

8593
Calling a function without assigning the return value to anything (e.g.
8694
`print('hello')` instead of `thingy = print('hello')`) simply throws away

0 commit comments

Comments
 (0)