F
Fuzzyman
Steven said:complex,
Interesting. I would have thought that my example was pretty simple.
Maybe it would be helpful to generalize it to:
def foo(bar, baz, spam=badger(x, y, z)):
...
All it does is use a default value that was produced by a function call.
I'm surprised you haven't run into this situation before...
Of course, what is complex or simple is a matter of personal opinion. I
use this pattern so often that it's quite simple to me, but I guess I
can understand that if you don't use such a pattern, it might seem
foreign to you.
Steve
Hello Steve,
It wasn't that part of the example that I thought was over complex.
(although it's not a 'pattern' I use often). You suggested that if we
had dynamic evaluation of default values, you would have to replace it
with :
Now that I thought was over complex... when all you wanted to do was
put a constant into your default value !
Having said that I see Steve's point about not knowing the namespace
when the function will be called.
Regards,
Fuzzy
http://www.voidspace.org.uk/python/index.shtml