Skip to content

Instantly share code, notes, and snippets.

x = 'foo'
y = x
print x # foo
y += 'bar'
print x # foo
x = [1, 2, 3]
y = x
print x # [1, 2, 3]
y += [3, 2, 1]
x = something # immutable type
print x
func(x)
print x # prints the same thing
x = something # mutable type
print x
func(x)
print x # might print something different
#The @ symbol indicates that we are applying
#the decorator to the function hello()
@timer
def hello():
pass
#The @ symbol indicates that we are applying the decorator to
#the function hello()
@timer
def hello():
pass
#Code For decorator
import timeit
import logging
def timer(func):
def wrap(*args, **kwargs):
started_at = time.time()
result = func(*args, **kwargs)
logging.info(time.time() - started_at)