Closed piac closed 8 years ago
Hello, I know it's been two years, but has this been addressed? I would like to use the timeit.timeit method and I'm running into the same namespace error the parent had: I cannot import methods from main. Is there a way to achieve this?
Hi @saeranv, I had actually looked at this and our is a different case.
The 'real' reason is that there is no main. And there is no main because in GhPython there is no file: you can imagine it as code were run from the 'exec' function.
However, this is usually a minor problem. We can work around this (now; I think earlier the version of timeit was not supporting IronPython).
I uploaded a sample at the address: http://www.grasshopper3d.com/xn/detail/2985220:Comment:1520589
I will close this bug item, as there is no way to import this as a nameless module (it's like the interactive interpreter).
http://www.grasshopper3d.com/forum/topics/performance-profiling-in-ghpython
From a quick check, it seems that the solution is outlined in answer 1: http://stackoverflow.com/questions/8264596/how-do-i-set-name-to-main-when-using-ironpython-hosted