[Python-ideas] Re: default parameter in fuctions to clean up flow

2020-08-11 Thread Peter Moore
Yes exactly. datetime.datetime.now() would call the function and datetime.datetime.now would pass the function. So it would be nice to have a way to pass a deferred call. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an e

[Python-ideas] Re: default parameter in fuctions to clean up flow

2020-08-11 Thread Peter Moore
Ok my thoughts was that python is such an elegant language, a process that could add a non static value (a callable or generator for example) to a function's default parameter would add more elegance to the default handling. what a decorator and a helper function do is to double the amount of fu

[Python-ideas] Re: default parameter in fuctions to clean up flow

2020-08-11 Thread Peter Moore
S.O post was this one. https://stackoverflow.com/questions/50653182/can-a-lambda-or-other-method-be-used-as-a-default-parameter-in-python ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.o

[Python-ideas] Re: default parameter in fuctions to clean up flow

2020-07-27 Thread Peter Moore
I should add to this (as I cant edit my post) that please note it is not a constant we are adding. Its a value that will change each time you call the function. It could be a GUID or rand number too. In this case its the current time. ___ Python-ideas

[Python-ideas] default parameter in fuctions to clean up flow

2020-07-27 Thread Peter Moore
I have had a long standing unanswered question on on stackoverflow: is it possible to pass a function to a default parameter so that you could do in essence things like this. def time_diff(target_time, curr_time= lambda : datetime.now() ): return curr_time - target_time this would be an s