How do I access a variable from another DAT?

Say I have Text DAT text1 containing:

dat_pretty_name = 'Wonderful String'

And then I have another Text DAT text2 which I want to somehow print ‘Wonderful String’ by invoking the variable dat_pretty_name from text1

How do I go about doing this? Is there some way just to import that one variable value from text1 into text2?

You could reference your other text DAT as a module like this, and then print it’s variables.

python_mod.toe (5.1 KB)

Do ctrl-r on ‘text1’

Does that help?

Jayson

1 Like

Thanks a lot Jayson, that does it. Totally forgot about module.

FWIW, since posting, I just changed my ‘schema’ so that text1 is no longer a text dat, but a table that has the pretty name in one cell, and some other stuff in another, so that I can just reference things by cell coordinates [x,x].

1 Like

just a note. You can also use import text2

2 Likes

oo didn’t know that! thanks!

If text2 has some variables that have the same names as some variables in text1, could it cause a conflict?

No. You can only access them via the namespace. So text2.thevariable.
You could do from text2 import thevariable but then you should be aware of conflicting names.

2 Likes

One more option which can be useful:

pretty_name = op(‘text2’).module.dat_pretty_name

2 Likes