Python Forum

Full Version: Accessing method as function object
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

How do you access a class method as a function object (not a function call)? The context is that I would like to use the help() function on random.shuffle(), but that results in an error because random.shuffle() prompts a function call, not the function itself.
help(random.shuffle)
In [1]: class Foo:
   ...:     def __init__(self, num):
   ...:         self.num = num
   ...:     @property
   ...:     def double(self):
   ...:         return self.num + self.num
   ...:

In [2]: obj = Foo(5)

In [3]: obj.double
Out[3]: 10