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 9229963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:42:13+00:00 2026-06-18T05:42:13+00:00

According to the docs it should work to combine @property and @abc.abstractmethod so the

  • 0

According to the docs it should work to combine @property and @abc.abstractmethod so the following should work in python3.3:

import abc

class FooBase(metaclass=abc.ABCMeta):

    @property
    @abc.abstractmethod
    def greet(self):
        """ must be implemented in order to instantiate """
        pass

    @property
    def greet_comparison(self):
        """ must be implemented in order to instantiate """
        return 'hello'

class Foo(FooBase):
    def greet(self):
        return 'hello'

test the implementation:

In [6]: foo = Foo()
In [7]: foo.greet
Out[7]: <bound method Foo.greet of <__main__.Foo object at 0x7f935a971f10>>

In [8]: foo.greet()
Out[8]: 'hello'

so it is obviously not a property, because then it should work like that:

In [9]: foo.greet_comparison
Out[9]: 'hello'

Maybe I’m to stupid or it simply doesn’t work, somebody has an idea?

  • 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-06-18T05:42:15+00:00Added an answer on June 18, 2026 at 5:42 am

    If you want greet to be a property, you still need to use the @property decorator in your implementation:

    class Foo(FooBase):
        @property
        def greet(self):
            return 'hello'
    

    All that an ABC metaclass does is test wether or not you have provided the same name in the concrete class; it doesn’t care if it is a method or a property or a regular attribute.

    Because it doesn’t care, it doesn’t magically apply property decorators either. This is a good thing; perhaps in a specific implementation a static attribute is enough to satisfy the requirement, and a property would be overkill.

    The purpose of a ABC metaclass is to help you detect gaps in your implementation; it never was intended to enforce the types of the attributes.

    Note that before Python 3.3 you can not combine a @property with an @abstractmethod. You would have to use an @abstractproperty decorator instead. There is an ambiguity there when your property needs more than a simple getter in that case; Python 3.3 covers that case much better (see issue 11610 for the painful details).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to the iBatis docs , using byte? as a type value should work
According to docs at http://code.google.com/p/minify/wiki/UriRewriting $min_serveOptions['rewriteCssUris'] = false; I should be able to add
According to the docs String text = String.format(%5.1e, 3.1415f); Should produce something like 3.1E+00
I'm using a System.Windows.Forms.TextBox . According to the docs, the MaxLength property controls the
According to the docs here I should be able to use Y.one(#container).appended( newImages, function(){
According to the DBUnit docs link it should support using a CLEAN_INSERT when using
According to YouTube's docs: https://developers.google.com/youtube/2.0/developers_guide_protocol_playlists I can go to the following URL to retrieve
According to this http://docs.nuget.org/docs/start-here/using-the-package-manager-console I should see the PM prompt and commands like get-packages
According to the docs I should be able to simply define this in my
According to the docs, jQuery.extend() is a solution to execute both a deep and

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.