Python Forum
Accessing method as function object
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing method as function object

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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

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
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to call an object in another function in Maya bstout 0 272 Apr-05-2021, 07:12 PM
Last Post: bstout
  Building a method name in a function ffgth 9 727 Oct-19-2020, 01:21 PM
Last Post: buran
  accessing value array object ortollj 1 491 Aug-30-2020, 12:00 PM
Last Post: ortollj
  subprogram issues: cannot unpack non-iterable function object error djwilson0495 13 1,913 Aug-20-2020, 05:53 PM
Last Post: deanhystad
  accessing a second level nested function varsh 3 871 Aug-13-2020, 06:57 AM
Last Post: varsh
  function/method help myv5285 3 971 May-17-2020, 04:19 AM
Last Post: buran
  function/nonetype object is not iterable nanok66 5 1,209 May-08-2020, 07:39 PM
Last Post: nanok66
  How to mock an object that is created during function call? Schlangenversteher 0 699 Jan-31-2020, 01:36 PM
Last Post: Schlangenversteher
  function vs method prateekshaw 2 765 Nov-14-2019, 07:00 PM
Last Post: DeaD_EyE
  print all method and property of list object engmoh 4 1,069 Oct-26-2019, 05:33 PM
Last Post: engmoh

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020