-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 08 September 2013 10:43 PM, Saager Mhatre wrote:

> 
> 
>> With a verb name like *register* I'd much prefer to call the
>> function as opposed to using it as a decorator. The more
>> idiomatic decorators have noun names, viz- property, classmethod,
>> staticmethod, unittest.expectedFailure, (or the one you used
>> below) contextmanager, etc. I'll admit 'unittest.skipTest' is an
>> anomaly, but I've always felt that the unittest module was a
>> somewhat unpythonic 1-1 port of JUnit, so we'll let that one 
>> slide. :)
> 
>> The other reason in favour of the invocation syntax over the
>> decorator syntax would be that the 'atexit.register' function is
>> variadic and it would not be possible to send in the arguments to
>> be passed in at exit if 'atexit.register' were used as a
>> decorator. Of course, we could nest the decorated function in
>> another function to provide a lexical closure that would then
>> allow us to specify those arguments, but explicitly declaring the
>> parameters to the cleanup function and explicitly passing them
>> to register just seems much more idiomatic to me.

Idiomatic code is always quite subjective. It is easier to differentiate
between good code vs bad code than between really good code vs idiomatic
(beautiful) code.

I can write a very nasty looking decorator function which hides a lot
of complexity (possibly with horrible code) and then decorate a function
with it. Is it idiomatic - Probably not. But there would be people
who think otherwise.

I gave that example as it was given in the Python documentation
for atexit module.

http://docs.python.org/2/library/atexit.html#module-atexit

> 
> 
> [...]
>> _______________________________________________ BangPypers
>> mailing list BangPypers@python.org 
>> http://mail.python.org/mailman/listinfo/bangpypers
>> 
> 
> I realize I'm a little late to the thread, but just thought I'd put
> in my 2c.
> 
> - d _______________________________________________ BangPypers
> mailing list BangPypers@python.org 
> https://mail.python.org/mailman/listinfo/bangpypers
> 

- -- 
Regards,

- --Anand

-
--------------------------------------------------------------------------------------
Software Architect/Consultant
anandpil...@letterboxes.org

Please note my updated email address <anandpil...@letterboxes.org>.
Kindly update your address books.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSLdLPAAoJEMTxYeOp9eaoKtYIAL7wknmJk8G31PHnTNaALDDw
stdHN7Ln0kvLnCCIJmkAQeSa3mFPkG127RHneglmoUXptFL/9KMWlQJz6YHnzMWd
CHK3+PNeFaDDqMQpU9b/pzbzMEq/UM4BvtFPQB7LhKWZgWa/YeMRQNHk/jS6+fl+
y92zSY0gaZEwRJj85Yh+WNyMlHoj3dRHhBtVSTRikHiImBv0CMNx49HymBATUm8E
z0G5eGd8W9okGkaiGjCcx4JSXZ+A9WiP3M46GUYY21I3Em+ocnxfD6wQIUzSlOj+
ZJgU653joCQbUTcwVBjEEsGc3OkavbMTilkuBg/30QeHf9H1ohgcq7zRQSEJ0Mc=
=ibBh
-----END PGP SIGNATURE-----
_______________________________________________
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers

Reply via email to