randy3k / Terminus

Bring a real terminal to Sublime Text
https://packagecontrol.io/packages/Terminus
MIT License
1.39k stars 81 forks source link

python build system #271

Closed yuanyangwangTJ closed 3 years ago

yuanyangwangTJ commented 3 years ago

Glad to find this excellent plugin for sublime text. I use it to build my python system following the guidance of plugin. Compared with default setting in sublime, this plugin make it possible to run python in a interactive environment in panel. At the beginning , it works well, but I found a problem about python file operation.

Detail

I open a python file, but not open the folder where it is. The python code is as following:

if __name__ == "__main__":  
    with open('test.txt', 'w', encoding='utf-8') as fp:
        fp.write('hello world')
    with open('test.txt', encoding='utf-8') as fp:
        print(fp.read())

It run successfully and print hello world, but I can't find test.txt, I guess it may be caused by the target in setting. May be the target terminus_cancel_build? A supplement, if I open the folder where the python file is and run python, I can find test.txt.

So how can I to run python file while not opening folder and in a relative path, I would appreciate it if you could provide some help.

dogira commented 3 years ago

You could use os.path? If you know where you are writing to that could be viable.

yuanyangwangTJ commented 3 years ago

You could use os.path? If you know where you are writing to that could be viable.

Thanks for your notice, I found that the os.path is root directory C:\Users\user when I open a file in anywhere, this may be link to the way of working in sublime text. But how can I make the os.path get the right and actual path?

yuanyangwangTJ commented 3 years ago

You could use os.path? If you know where you are writing to that could be viable.

With the help of your notice, I found the problem in my "working_dir" setting, I modify and run ok. The problem is solved. Thanks for your help again!

dogira commented 3 years ago

You could use os.path? If you know where you are writing to that could be viable.

With the help of your notice, I found the problem in my "working_dir" setting, I modify and run ok. The problem is solved. Thanks for your help again!

I do not know if I did much there but that is great man. Have fun. :)