M
M
Mark Adams2016-04-07 01:17:01
Python
Mark Adams, 2016-04-07 01:17:01

Why does Terminal and Sublime Text show different results when running Python3 on OSX?

Here is the code:

import os.path 
if __name__ == '__main__':
  yout_path = os.path.abspath(os.curdir)
  print(str(yout_path) + '/')

Run result in Terminal: /Users/ilya/
Run result in ST: /Users/ilya/Desktop/put/
Why is that? How to fix it in terminal?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2016-04-07
@ilyakmet

because the path is relative to the current directory, which can be anything.
run in terminal:

cd /Users/ilya/Desktop/put/; python -c "import os.path;yout_path = os.path.abspath(os.curdir);print(str(yout_path) + '/')"
and rejoice.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question