global property error

hi to all
i get every time a error when i try to make a string propery to a global propert
and it cant find the property
AttributeError: ‘module’ object has no attribute ‘prop1’
and i use the code

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

own.sprop = GameLogic.prop1

sprop is my property from my string dos any1 know this problem???:confused:

What is said is that GameLogic doesn’t have prop1.
Are you trying to copy the global to the object or the object to the global?
your code right now copies the global property to the object’s (but can’t find the global property). If you flip it around to GameLogic.prop1 = own.sprop it will copy the object’s property to the global (and create the global property if it doesn’t exist)

do a little check before getting the property

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

if hasattr(GameLogic, "prop1"):
    own.sprop = GameLogic.prop1

thanks Cyborg_ar but just 1 qeustion what stands hassattr for i know it means (has attribute)
but what dos it do if i put it in the script cus im not know what it dos if i do
just asking for the next time i use it

hasattr returns true if the specified object has the specified attribute, in this case if GameLogic has “prop1”, so we use it in an if to prevent the script from getting a property that doesn’t exist

Basically it checks whether “gamelogic.prop1” exists. If it does exist, then it executes the next indented lines (in this case, copying the global variable to the object’s property). If not, it skips them (preventing an error).

thanks for your help it helps me alot :wink: