Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Accessing method as function object
#1
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.
Quote
#2
help(random.shuffle)
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

Quote
#3
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."
https://freedns.afraid.org
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  accessing value array object ortollj 1 152 Aug-30-2020, 12:00 PM
Last Post: ortollj
  subprogram issues: cannot unpack non-iterable function object error djwilson0495 13 430 Aug-20-2020, 05:53 PM
Last Post: deanhystad
  accessing a second level nested function varsh 3 377 Aug-13-2020, 06:57 AM
Last Post: varsh
  function/method help myv5285 3 510 May-17-2020, 04:19 AM
Last Post: buran
  function/nonetype object is not iterable nanok66 5 462 May-08-2020, 07:39 PM
Last Post: nanok66
  How to mock an object that is created during function call? Schlangenversteher 0 345 Jan-31-2020, 01:36 PM
Last Post: Schlangenversteher
  function vs method prateekshaw 2 362 Nov-14-2019, 07:00 PM
Last Post: DeaD_EyE
  print all method and property of list object engmoh 4 605 Oct-26-2019, 05:33 PM
Last Post: engmoh
  I'm trying to figure out whether this is a method or function call 357mag 2 654 Jul-04-2019, 01:43 AM
Last Post: ichabod801
  'function' object has no attribute 'write' paramiko lateublegende 1 1,869 Feb-12-2019, 09:03 PM
Last Post: nilamo

Forum Jump:


Users browsing this thread: 1 Guest(s)