Python Forum
Curious about decorator syntax
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Curious about decorator syntax
#7
Why do you consider

class A:
    def _foo_getter(self):
        return 10
 
    def _foo_setter(self, value):
        print('Hello there!')
 
    def _foo_deleter(self):
        print('Deleting foo')
 
    foo = property(_foo_getter, _foo_setter, _foo_deleter)
clearer than

class A:

    @getter
    def foo(self):
        return 10

    @setter 
    def foo(self, value):
        print('Hello there!')

    @deleter 
    def foo(self):
        print('Deleting foo')


I think the symmetry of my suggestion would be preferable. I liken the existing way to giving a list of items as

    1. first item
    2. second item
    C. third item
While the intent is understood, it lacks symmetry and clarity. It brings to mind a beef I have with Windows in that the registry entries are, in my opinion (and in the opinion of at least one former MS engineer), moronic.

Special folder      Registry entry name
--------------      -------------------
My Music            My Music
My Pictures         My Pictures
My Video            My Videos
My Documents        Personal
This, after all, is why Python has standards for the naming of classes, methods, etc.
Reply


Messages In This Thread
Curious about decorator syntax - by rjdegraff42 - Apr-30-2023, 01:58 PM
RE: Curious about decorator syntax - by Gribouillis - Apr-30-2023, 05:31 PM
RE: Curious about decorator syntax - by rjdegraff42 - Apr-30-2023, 05:57 PM
RE: Curious about decorator syntax - by Gribouillis - Apr-30-2023, 08:13 PM
RE: Curious about decorator syntax - by rjdegraff42 - May-02-2023, 02:23 PM
RE: Curious about decorator syntax - by Gribouillis - May-02-2023, 02:47 PM
RE: Curious about decorator syntax - by rjdegraff42 - May-02-2023, 06:24 PM
RE: Curious about decorator syntax - by Gribouillis - May-02-2023, 07:38 PM
RE: Curious about decorator syntax - by rjdegraff42 - May-02-2023, 07:58 PM
RE: Curious about decorator syntax - by Gribouillis - May-02-2023, 08:06 PM
RE: Curious about decorator syntax - by rjdegraff42 - May-02-2023, 08:25 PM
RE: Curious about decorator syntax - by Gribouillis - May-02-2023, 08:54 PM
RE: Curious about decorator syntax - by rjdegraff42 - May-03-2023, 12:57 AM
RE: Curious about decorator syntax - by rjdegraff42 - May-03-2023, 01:40 AM
RE: Curious about decorator syntax - by rjdegraff42 - May-03-2023, 01:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  the order of running code in a decorator function akbarza 2 646 Nov-10-2023, 08:09 AM
Last Post: akbarza
  ABC Module and @property decorator, Pythonic Way? muzikman 21 6,077 Aug-18-2021, 06:08 PM
Last Post: muzikman
  decorator adamfairhall 0 1,626 Aug-18-2020, 08:38 AM
Last Post: adamfairhall
  Use of @property decorator ruy 16 7,075 Jun-09-2020, 05:29 PM
Last Post: buran
  Decorator staticmethod Use Cases Devarishi 3 2,766 May-20-2019, 04:27 AM
Last Post: Devarishi
  How can we override decorator? bhojendra 2 9,672 May-12-2019, 11:15 PM
Last Post: ichabod801
  curious syntax with dictionary item inselbuch 3 2,897 Mar-09-2019, 04:21 PM
Last Post: ichabod801
  Decorator question Dan741 1 2,493 Nov-14-2018, 10:05 AM
Last Post: wavic
  Decorator toy code throws syntax errors kevinxhi 3 3,729 Sep-04-2017, 03:01 AM
Last Post: kevinxhi
  accessing variables from a decorator ashwin 1 3,184 Jun-30-2017, 04:11 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020