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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:31:35+00:00 2026-06-13T20:31:35+00:00

Im trying to create a class with some formatting options. But i can’t figure

  • 0

Im trying to create a class with some formatting options. But i can’t figure out how to do it properly…

The code produced the following error:

AttributeError: ‘NoneType’ object has no attribute ‘valuesonly’

class Testings(object):

    def format_as_values_only(self,somedata):
        buildstring=somedata.values()
        return buildstring

    def format_as_keys_only(self):
        pass

    def format_as_numbers(self):
        pass


    def get_data_method(self):
        self.data= {'2_testkey':'2_testvalue',"2_testkey2":"2_testvalue2"}

        @property
        def valuesonly(self):
            return format_as_values_only(self.data)

test=Testings()
print test.get_data_method().valuesonly 

The important thing for me is to be able to get the formatters like: class.method.formatter or so…

Thanks a lot for any hints!

  • 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-13T20:31:37+00:00Added an answer on June 13, 2026 at 8:31 pm

    You can’t do things this way. Methods are just functions defined directly inside a class block. Your function is inside another function, so it’s not a method. The property decorator is useless except in a class block.

    But, more fundamentally, function definitions just create local names, the same as variable assignments or anything else. Your valuesonly function is not accessible at all from outside the get_data_method function, because nothing from within a function is accessible except its return value. What you have done is no different than:

    def get_data_method(self):
        a = 2
    

    . . . and then expecting to be able to access the local variable a from outside the function. It won’t work. When you call get_data_method(), you get the value None, because get_data_method doesn’t return anything. Anything you subsequently do with the result of get_data_method() is just operating on that same None value.

    If you want to access things using the syntax you describe, you will need to make get_data_method return an object that has properties like valuesonly. In other words, write another class that provides a valuesonly property, and have get_data_method return an instance of that class. A rough outline (untested):

    class DataMethodGetter(object):
        def __init__(self, parent):
            self.parent = parent
    
        @property
        def valuesonly(self):
            return format_as_values_only(self.parent.data)
    
    class Testings(object):
        # rest of class def here
        def get_data_method(self):
            self.data = {'blah': 'blah'}
            return DataMethodGetter(self)
    

    However, you should think about why you want to do this. It’s likely to be simpler to set it up to just call valuesonly directly on the Testing object, or to pass a flag to get_data_method, doing something like get_data_method(valuesonly=True).

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

Sidebar

Related Questions

I am trying to figure out a way to create a class to group
I'm trying to create some Menu Item with Image & Label, using barry's class
I'm trying to create a class that can instantiate arrays at runtime by giving
For some reason when I am trying to create a class which implements IHttpHandler
Trying to create an uebersimple class that implements get enumerator, but failing madly due
I am trying to create an class object to a class but I keep
I'm trying to create a class that can be added to a Layout file,
I'm trying to create a Mockito mock object of a class with some rather
I'm using Eclipselink and I'm trying figure out the best way to create a
I am trying to do some string concatenation/formatting, but it's putting all the parameters

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.