8 Comments
User's avatar
Abbaan Nassar's avatar

I wonder, is the python function the coffee machine, or is the python language the coffee machine, or is my operating system the coffee machine? Or is my computer the coffee machine?

Expand full comment
Stephen Gruppetta's avatar

In the analogy, the coffee machine represents the function. You provide it with stuff (coffee, water, electricity) and these are the arguments you use when you call the function, and it gives you hot, liquid coffee—the function's return value.

Of course, analogies are just that, of course, and they always fail if you push to far, but this is a good way of visualising what a function does

Expand full comment
Srikrishna Sajjarao's avatar

Stephen!!!!

Wow, I am trying to understand the function concept from the last 5 days. You made me understand it in 10 mins.

Thankyou so much. Love you

Expand full comment
Stephen Gruppetta's avatar

I'm glad you found it useful! Hopefully you'll find some other interesting articles on The Stack, too, although some may cover slightly more advanced topics…

…but you may enjoy The Python Coding Book, too ;-)

Expand full comment
Slack System's avatar

I really love your analogies they work so well

Expand full comment
Stephen Gruppetta's avatar

Thank you

Expand full comment
Slack System's avatar

> Unless you're prepared to tilt your head in an awkward position, open your mouth, and position it directly in the coffee stream's path—I don't recommend this—the coffee will go to waste.

If you actually *do* do this though, then you are the variable

Expand full comment
Stephen Gruppetta's avatar

Yes and no. With analogies it always depends on interpretation.

If you do this, you’re not “storing” the coffee for later use but using it directly. Later in the article, I link this to calling the function directly within another function call’s parentheses…

..but yes, you could be the variable too, under a different interpretation!!

Expand full comment