---
title: "Discussion on \"When should default function arguments be evaluated?\" | Hashnode"
description: "Discussion on \"When should default function arguments be evaluated?\". I was writing my first app and I found a bug. The date time column in my database always had the same value. I found out that this value changed upon restarting the server. \nThis was the problematic piece of code: \ndef foo(param, now=datetime.now()):..."
url: "https://hashnode.com/posts/when-should-default-function-arguments-be-evaluated/5f37e11d0801bf3f76e5f512"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [When should default function arguments be evaluated?](https://rahem027.hashnode.dev/when-should-default-function-arguments-be-evaluated?utm_source=hashnode&utm_medium=feed)

I was writing my first app and I found a bug. The date time column in my database always had the same value. I found out that this value changed upon restarting the server. This was the problematic piece of code: def foo(param, now=datetime.now()):...

Aug 15, 2020 · 2 min read · rahem027.hashnode.dev  
Updated Aug 17, 2020  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#python3](https://hashnode.com/tag/python3)
-   [#cpp](https://hashnode.com/tag/cpp)
-   [#programming-languages](https://hashnode.com/tag/programming-languages)

## Written by

[Hemil Ruparel](https://hashnode.com/@rahem027)

@rahem027

  
[View profile](https://hashnode.com/@rahem027)

Would love to help you

## Responses 1

Markdown supported · ⌘↵ to post

[Sean Charles](https://hashnode.com/@emacstheviking)

[Aug 15, 2020](https://hashnode.com/posts/when-should-default-function-arguments-be-evaluated/5f37e11d0801bf3f76e5f512/comment/5f37f423c4d5973f55c90883)

Welcome to the Python club dude!

[docs.python-guide.org/writing/gotchas](https://docs.python-guide.org/writing/gotchas/)

[Hemil Ruparel](https://hashnode.com/@rahem027)

[Aug 15, 2020](https://hashnode.com/posts/when-should-default-function-arguments-be-evaluated/5f37e11d0801bf3f76e5f512/comment/5f37f423c4d5973f55c90883#reply-5f37f5d40801bf3f76e5f61f)

I really dont want this kind of gotcha 🤣🤣😝😝😝

[Sean Charles](https://hashnode.com/@emacstheviking)

[Aug 15, 2020](https://hashnode.com/posts/when-should-default-function-arguments-be-evaluated/5f37e11d0801bf3f76e5f512/comment/5f37f423c4d5973f55c90883#reply-5f37f932c4d5973f55c908d8)

[Hemil Ruparel](https://hashnode.com/@rahem027) Who does!? When learning something new there are always surprises to be found, some pleasant other downright baffling.
