-3
import numpy as np

class MyClass:

        a = int()
        b = float()
        c = np.array([0 for i in range 10])

        def Memberfunction():

            print("Hii")
Keyur Potdar
  • 7,158
  • 6
  • 25
  • 40

1 Answers1

1
class test_class():
    def __init__(self, some_func):
        self.some_value = 2    
        setattr(type(self), some_func.__name__, some_func)

def my_requested_func(self):
    print(self.some_value)

class_instance = test_class(my_requested_func)
class_instance.my_requested_func()

This should work, but I dont see any reason for you wanting to do this.

Rohi
  • 814
  • 1
  • 9
  • 26