fumitoh / modelx

Use Python like a spreadsheet!
https://modelx.io
GNU Lesser General Public License v3.0
96 stars 21 forks source link

"parent" not defined in dynamic space formula #26

Closed alebaran closed 4 years ago

alebaran commented 4 years ago

What is the reason "parent" not defined in dynamic space formula? See the code below.

from modelx import *
new_model()
def s_arg(t):
    print(parent)
    pass

s = new_space(formula=s_arg)
s(1)
fumitoh commented 4 years ago

Try _space.parent. _space is s itself.

alebaran commented 4 years ago

Thank you. Why didn't work at the first place? I thought dynamic space formula is evaluated in the base space namespace, which has parent.

fumitoh commented 4 years ago

You're right. The dynamic space formula is evaluated in the base space namespace. It's just that the namespace is different from dir(s)