-3

I would like to create object based on arguments I provided.

For example

abilities1 = {
    "empathy" : 1000
}

abilites2 = {
    "strength" : 100
}

And now I want to pass abilities dict to class which automatically determine if object should be Man class (strength ability in dict) or Women class (empathy ability in dict).

Is there any technique to write this class? I would like to avoid IFs.

Thank you in advance and sorry for stereotyping genders :)

dannyx
  • 33
  • 1
  • 5

1 Answers1

1

You can take a look at concept of python Meta Programming and based on conditions, can define your classes in simple string and use eval() and exec() keywords if I'm no mistaken.

You can take a look at this link:

What's the difference between eval, exec, and compile?

Reza Akraminejad
  • 1,412
  • 3
  • 24
  • 38