expressions in Python function definition default values are evaluated only once, when the functions are defined

This commit is contained in:
Seth Schoen
2012-07-03 00:55:53 -07:00
parent 721f28068f
commit 4136f32091
+2 -1
View File
@@ -74,7 +74,8 @@ class session(object):
# a challenge, we have state="testchallenge", but live="False".
return sessions.hget(self.id, "state")
def create(self, timestamp=int(time.time())):
def create(self, timestamp=None):
if timestamp is None: timestamp = int(time.time())
if not self.exists():
sessions.hset(self.id, "created", timestamp)
sessions.hset(self.id, "live", True)