On 24/05/13 02:56, Paul Moore wrote:
On 23 May 2013 17:00, Walter Dörwald <wal...@livinglogic.de> wrote:
Should it be possible to register multiple types for the generic function
with one register() call, i.e. should:
@fun.register(int, float)
def _(arg, verbose=False):
...
be allowed as a synonym for
@fun.register(int)
@fun.register(float)
def _(arg, verbose=False):
No, because people will misread register(int, float) as meaning first
argument int, second float. The double decorator is explicit as to what is
going on, and isn't too hard to read or write.
I don't think that they will. Being able to register multiple types with a single call
reads very naturally to me, while multiple decorators still looks weird. Even after many
years of seeing them, I still get a momentary "What the hell...?" moment when I
see two decorators on one function. That's only going to be increased when both
decorators are the same (apart from the argument). The double decorator form above looks
to me as weird as:
x = func(a)
x = func(b)
would. I have to stop and think about what is going on, and whether or not it
is a mistake.
So I am a strong +1 on allowing multiple types to be registered in one call.
--
Steven
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com