From the tutorial: "A class definition is an executable statement."
Is the following recommended in a script?
my_switch = False
if my_switch:
class Hello:
def __init__(self):
self.greeting = "Hello!"
else:
class Hello:
def __init__(self):
self.greeting = "Salut!"
You can even do
class Hello:
def __init__(self):
self.greeting = "Hello!"
class Salut:
def __init__(self):
self.greeting = "Salut!"
if my_switch:
Hello = Salut
(note that your code needs lower-case Class keywords...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With