@andymitchhank/

default-function-args

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class TestObject(object):
  pass


def dont_do_this(t=TestObject()):
  return t


one = dont_do_this()
two = dont_do_this()

print(one is two)


def better_way(t=None):
  if not t:
    t = TestObject()
  return t


one = better_way()
two = better_way()

print(one is two)