On Tuesday 16 June 2015 16:06, Mark Lawrence wrote: > On 16/06/2015 00:57, Steven D'Aprano wrote: [...] >> Naturally you can always override the default by explicitly specifying a >> keyword argument edir(obj, dunders=flag). >> >> Thoughts and feedback? Please vote: a module global, or a flag on the >> object? Please give reasons, and remember that the function is intended >> for interactive use. >> >> > > For interactive use I'd be perfectly happy with just the keyword > argument. Why bother toggling something when I can explicitly set it in > the call each and every time? If I have to choose it's a flag on the > object, just no competition.
The idea is to set the default behaviour: does edir(obj) display dunder methods by default or not? I've found that many people don't want to see the dunder methods, and find dir() less pleasant or useful because it shows them. Others disagree and want to see them. So you can set the default behaviour you want, and then only worry about giving an explicit argument when you want the opposite. There is no intention for people to toggle the flag between calls! # don't do this! edir.dunders = True edir(x) edir.dunders = False edir(y) # do this instead edir.dunders = True # if that is your preferred setting edir(x) edir(y, dunders=False) -- Steve -- https://mail.python.org/mailman/listinfo/python-list