Talk = ''
def create_greeting(greeting=None):
global Talk
Talk = greeting + ' fellow blogsters! '
return Talk
create_greeting('Hello')
Talk += 'How are we doing today?'
def create_sign(greeting, decoration = "*"):
line = decoration * len(greeting) # len(STRING) gets the length of a string
print(line)
print(greeting)
print(line)
create_sign(Talk)
Objects
- You can make functions by
- Named references should be thought of as objects rather than variables
- Assignment attaches a name to the object
- Changing assignment from one reference to another puts two different names referring to the same object
- The is operator determines if references are the same object
- Python garbage collector reclaims unreachable objects
- Function arguments can be specified with defaults
- The default expressions are evaluated once when def is executed for the first time
- Global references can be read from a local scope but only when you specify