Paul Bryan <pbr...@anode.ca> writes: > Maybe this will help: > >>>> def get(key, default): > ... print("entering get") > ... print(f"{key=} {default=}") > ... print("exiting get") > ... >>>> def generate_default(): > ... print("entering generate_default") > ... print("exiting generate_default") > ... return 1 > ... >>>> get("a", generate_default()) > entering generate_default > exiting generate_default > entering get > key='a' default=1 > exiting get >>>>
OK, so it even has nothing to do with dict.get(). It is just about the way function arguments are evaluated. Your example above illustrates nicely that Python does what I would expect, although from the examples others have given, I might have to adjust my expectations when using other languages. Cheers, Loris -- This signature is currently under construction. -- https://mail.python.org/mailman/listinfo/python-list