PYKX not allowing to change Python attribute of Q Object

https://learninghub.kx.com/forums/topic/pykx-not-allowing-to-change-python-attribute-of-q-object

I am trying to do the following:

```

import pykx

old=":host:Port:user:old"

pykx.q.my_handle=old

new=":host:Port:user:new"

pykx.q.my_handle=new

```

The above works as expected. If I then try to access vía Python or directly from Q memory I would get the string in the new var.

```

print(pykx.q.my_handle)

print(pykx.q('string .my_handle'))

```

**However**, if I access the attribute (for any reason) before setting It to new value then something *weird* happens:

```

import pykx

old=":host:Port:user:old"

pykx.q.my_handle=old

print(f"my handled: {pykx.q.my_handle}")

new=":host:Port:user:new"

pykx.q.my_handle=new

#prints old

print(pykx.q.my_handle)

#prints new

print(pykx.q("string .my_handle"))

```

Anyone knows why? **Note** my handled has to be refreshed with new password/token whenever needed, in theory I vannot think about a use cas

Copying answer from SO thread for reference:

https://stackoverflow.com/questions/79626532/pykx-not-allowing-to-change-python-attribute


. Notation is for the context interface and namespaces

``` pykx.q.myhandles.a = 1 pykx.q.myhandles.b = 2

<p>For variables in root namespace use <code>[]</code></p>
pykx.q[‘handle_a’] = 1
pykx.q[‘handle_b’] = 2