Hallo,
ich versuche gerade folgende Java Klasse in Python umzuändern:
Mein Versuch in Python:
Warum ist die der Wert von variable dann 0?
Danke im Vorraus.
ich versuche gerade folgende Java Klasse in Python umzuändern:
Java:
class Test {
int id;
int variable;
public Test(int id) {
switch(id) {
case 1: variable =1; break;
case 2: variable=2; break;
}
}
}
Python:
class Test:
variable =0
def __init__(self,id):
self.__id = id
if id == 1:
variable = 1
print("Test")
if id == 2:
variable = 2
t = Test(1)
print(t.variable) // Ergebnis ist 0
Warum ist die der Wert von variable dann 0?
Danke im Vorraus.