- 1

Python

Please I need help with the explanation and examples on how to make a function accepts a class object as the function attributes eg def function(classobj, classobj)

14th May 2021, 8:09 PM
Abdullah
7 odpowiedzi
+ 1
What about this : def func(anyclass=class): obj=anyclass() So if you provided another class it will be used, and if not the default class will be used.
14th May 2021, 8:52 PM
Alaa Aldeen Shammr
Alaa Aldeen Shammr - avatar
14th May 2021, 8:56 PM
Alaa Aldeen Shammr
Alaa Aldeen Shammr - avatar
0
Maybe you can set it as default parameters def func(x = class()):
14th May 2021, 8:36 PM
Alaa Aldeen Shammr
Alaa Aldeen Shammr - avatar
0
What if I'm using it for different classes
14th May 2021, 8:37 PM
Abdullah
0
Abdullah So u want your function to accept a value and a class as a parameters?
14th May 2021, 8:39 PM
Alaa Aldeen Shammr
Alaa Aldeen Shammr - avatar
0
Just accept a class object Let's say I have more than one classes and I want a function to use those classes to perform operations
14th May 2021, 8:42 PM
Abdullah
0
Let me try working with this thanks a lot
14th May 2021, 8:55 PM
Abdullah