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

  • Home
  • SEARCH
  • 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 8503871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:52:27+00:00 2026-06-11T01:52:27+00:00

I have put a Jira client for my django application together and now need

  • 0

I have put a Jira client for my django application together and now need to make it static but I can’t figure how to convert @property and @?.setter into static fields:

Say I have a class:

class nothing(object):
    auth_token = None
    counter = 0

    @property
    def a(self):
        self.log('getter')
        if not self.auth_token:
            self.auth_token = 'default'
        return self.auth_token

    @a.setter
    def a(self, value):
        self.log('setter')
        self.auth_token = value

    def log(self, value):
        self.counter+=1
        print '{0} called / counter: {1}'.format(value, self.counter)

and I want its methods to be static:

class nothing:
    auth_token = None
    counter = 0

    @staticmethod
    def get_a():
        nothing.log('getter')
        if not nothing.auth_token:
            nothing.log('auth_token value is None, setting')
            nothing.auth_token = 'default'
        return nothing.auth_token

    @staticmethod
    def set_a(value):
        nothing.log('setter')
        nothing.auth_token = value

    @staticmethod
    def log(value):
        nothing.counter+=1
        print '{0} called / counter: {1}'.format(value, nothing.counter)

can’t mark get_a as @property now as calling it will return an object and not actually call get_a. Methods are something I can live with but is there a way to have getters/setters instead?

  • 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-11T01:52:28+00:00Added an answer on June 11, 2026 at 1:52 am

    The easiest way is to make this class singleton. Instead of making methods static, override class with its instance:

    nothing = nothing()
    

    You can also use metaclasses if you want to have more than one instance.

    http://en.wikibooks.org/wiki/Python_Programming/MetaClasses

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

Sidebar

Related Questions

I have put together a .net winform application which consumes a wcf service exposed
I have put a sort of rudimentary preloading animation together with jQuery. You can
I have put together an ajax powered chat/social network with jquery, PHP - but
I have put together a navigation bar which expands a submenu on hover. See
i have put my site in dropbox so you can see it http://dl.dropbox.com/u/13722201/Dorset%20Designs/home.html when
I have put together an API that responds to a POST request by putting
I have put together an image scroller using jquery, like this function rotateImages(whichHolder, start)
I have put some Console.WriteLine calls in to test, but they aren't appearing in
I have put the code below inside my AppDelegate, but when I start the
i have put the image for app icon in app.but when i install my

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.