Brano Zarnovican wrote:
> But it still doesn't guarantee that __getitem__ accepts keywords.
> (What if somebody will extend the Tree class and overlook the
> definition of __getitem__ and define a "classic" one)
I deem it more likely that that same somebody will not overlook it and dump
your Tree
Brano Zarnovican wrote:
Q: Can you call 'f' with keywords that will be
ignored, without changing 'f's definition ?
no.
OK. Thank you for an answer.
what's the use case?
I have extended the dict class, so that my __getitem__ accepts an
optional parameter
[...]
But it still doesn't guarantee that
> > Q: Can you call 'f' with keywords that will be
> > ignored, without changing 'f's definition ?
>
> no.
OK. Thank you for an answer.
> what's the use case?
I have extended the dict class, so that my __getitem__ accepts an
optional parameter
class MyTree(dict):
def __getitem__(self, key,
Brano Zarnovican wrote:
> Q: Can you call 'f' with keywords that will be
> ignored, without changing 'f's definition ?
no.
> I would like to avoid code like this:
> k = {}
> k['optional'] = 2
> try:
> f(1, **k)
> except TypeError:
> f(1)
why would you write code like this? what's the use ca