Request for comments: use-cases for delayed evaluation
Dan Strohl
D.Strohl at F5.com
Thu May 17 12:14:13 EDT 2018
I could easily see using all of the examples; I run into this pretty regularly.
What about something like the following (which, honestly is really a combination of other examples).
If I have a function that has multiple parameters, each of which might be expensive, but it might break out earlier depending on how each one is evaluated... for example:
(pretending that "$" is a flag that says "evaluate later", and $(arg) is how you say "evaluate now")
def combine_unless_none(*$args, sep=', '):
""" if any arg evaluates to None, return '', otherwise join"""
for arg in args:
tmp_arg = $(arg)
If tmp_arg is None:
return "
return sep.join(args)
More information about the Python-list
mailing list