Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 650505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:03:37+00:00 2026-05-13T22:03:37+00:00

There was a beautiful way to organize class property in frame of one function,

  • 0

There was a beautiful way to organize class property in frame of one function, by using the apply decorator.

class Example(object):
    @apply
    def myattr():
        doc = """This is the doc string."""

        def fget(self):
            return self._half * 2

        def fset(self, value):
            self._half = value / 2

        def fdel(self):
            del self._half

        return property(**locals())

But now apply has been deprecated.

Is there any possibility to achieve such simplicity and readability for property, with new, came instead “extended call syntax”?


My approach is same as Anurag’s, but, I don’t now witch one is better, please look:

def prop(f):

    return property(**f())

class A(object):

    @prop
    def myattr():

        def fget(self):
            return self._myattr

        def fset(self, value):
            self._myattr = value 

        return locals()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:03:38+00:00Added an answer on May 13, 2026 at 10:03 pm

    Is there any possibility to achieve such simplicity and readability for property

    The new Python 2.6 way is:

    @property
    def myattr(self):
        """This is the doc string."""
        return self._half * 2
    
    @myattr.setter
    def myattr(self, value):
        self._half = value / 2
    
    @myattr.deleter
    def myattr(self):
        del self._half
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to make a function call only once? Suppose I have
There is a common practice of using <a></a> tags to markup beautiful buttons, with
Is there another (more beautiful) way to initialize this Javascript array? var counter =
I am using Beautiful Soup in Python. Here is an example URL: http://www.locationary.com/place/en/US/Ohio/Middletown/McDonald%27s-p1013254580.jsp In
I am just wondering if there is any beautiful way to iterate over two
I wonder if there's a more beautiful way to store a list of objects
There are two table s : one is the master and one the detail
I have an UIScrollView object that contain other views. There are UIViewController(s) that user
Is there ways to implement model validation with complex rules like if one radio
I'm writing a page scraper using beautiful soup, and have noticed it will sometimes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.