Annoying Python Property Problem

For some strange reason, I can’t set property values with Python.

For example, if I were to do this…

cont = GameLogic.getCurrentController()
own = cont.getOwner()
prop = own.prop

prop = 1

That would not set the value of prop to 1. Its a really weird and annoying problem. I have put up with it for a long time by using logic bricks to set property values, but I’m getting a little sick of that. Does anyone know how to fix this?

EDIT: I just found out that if I do this it works…

cont = GameLogic.getCurrentController()
own = cont.getOwner()
own.prop = 1

So is there a way to set property values after you define the property?

lol, this is not visual basic


cont = GameLogic.getCurrentController()
own = cont.getOwner()
own.prop = 1

that is the correct way, and you can assign the property as many times as you want, its not a definition.

Oh I just realized why you cant do it the first way. It’s probably just me, but I think that’s kinda weird that you can’t do it that way.

It’s not weird at all.
If you do:
own.prop = 1
Then that sets the objects property named ‘prop’ to 1
But if you do:
prop = 1
It just sets the variable named ‘prop’ to 1 and not the property on the object.
And when you do:
prop = own.prop
It sets the value of prop to the value of the property on the object. After that they are both separate variables.

Edit: What cyborg_ar said

it would be weird if you CAN do it that way xD