A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-August/047499.html below:

[Python-Dev] Another decorator syntax idea

[Python-Dev] Another decorator syntax ideabarnesc at engr.orst.edu barnesc at engr.orst.edu
Sat Aug 7 02:38:27 CEST 2004
Another decorator syntax idea

Using Guido's example:

--------------------
@ Symbols
--------------------

class C(object):

    @staticmethod
    @funcattrs(grammar="'@' dotted_name [ '(' [arglist] ')' ]", \
               status="experimental", author="BDFL")
    def longMethodNameForEffect(longArgumentOne=None,
                                longArgumentTwo=42):
        """This method blah, blah.

        It supports the following arguments:
	- longArgumentOne -- a string giving ...
        - longArgumentTwo -- a number giving ...

	blah, blah.

	"""
        raise NotYetImplemented

--------------------
decorate keyword
--------------------

class C(object):

    def longMethodNameForEffect(longArgumentOne=None,
                                longArgumentTwo=42):
        decorate:
            staticmethod
            funcattrs(grammar="'@' dotted_name [ '(' [arglist] ')' ]", \
                      status="experimental", author="BDFL")]
        """This method blah, blah.

        It supports the following arguments:
	- longArgumentOne -- a string giving ...
        - longArgumentTwo -- a number giving ...

	blah, blah.

	"""
        raise NotYetImplemented

Pros:
 - Doesn't hide the function name behind @ garbage.
 - 'decorate' is easier to look at than '@'.
 - 'decorate' is more meaningful to most readers than '@'.
 - Block structure isolates decorators from surrounding code,
   making them more readable.
 - Indentation rules are consistent with the rest of Python.

Cons:
 - Not pear shaped.

 - Connelly
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4