~/talk

13 fun facts about Python's return statement for savvy programmers

Talkat PyBay 2024 · on Saturday, 2024-09-21· [python]
links:none on file
slides:none on file

Live code demos show 13 facts with concrete examples: printing vs returning, a syntax error when using return outside a function, only one return ever executes (others are dead code), tuple unpacking to return multiple values, any object can be returned (including functions), Python defaults to None if no value is given, print returns None implicitly, return inside try/except returns chosen values, expression results (list comprehensions) return directly, and generator return raises StopIteration whose value is printed.

AI-written summary · about

  1. 0:00Introduction to talk
  2. 0:46What is a return statement
  3. 1:28Printing vs returning
  4. 2:33Syntax error outside function
  5. 2:55Single return execution per function
  6. 3:58Dead code after return
  7. 5:06Returning multiple values
  8. 6:52Returning any data type
  9. 7:34Returning mixed data types
  10. 7:56Default return of None
  11. 9:20Explicit return values
  12. 10:02Print function returns None
  13. 11:06Return in try-except blocks
  14. 13:40Return with expressions
  15. 15:03Return in generator functions
  16. 18:35Summary and Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.