Python Forum
things that work in terminal mode but not in sublime mode - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: things that work in terminal mode but not in sublime mode (/thread-34573.html)



things that work in terminal mode but not in sublime mode - alok - Aug-10-2021

I noticed, as an example in the Python Crash Course book . . . on pags 23 when usng terminal mode for the favorite_language example ( for .rstrip(), etc. ), it works flawlessly for me in terminal mode but I can't get it to work in sublime text,how come ?

Al


RE: things that work in terminal mode but not in sublime mode - perfringo - Aug-10-2021

What is/define “terminal mode” and “can’t get to work in sublime text”


RE: things that work in terminal mode but not in sublime mode - snippsat - Aug-10-2021

(Aug-10-2021, 03:46 PM)alok Wrote: Python Crash Course book . . . on pags 23
So if i take a quick look at book.
>>> favorite_language = ' python '
>>> favorite_language.rstrip()
' python'
>>> favorite_language.lstrip()
'python '
>>> favorite_language.strip()
'python'
So here(in book) run code in interactive interpreters,because of >>>
For sublime there is SublimeREPL

If running the same over as script/code save as eg test_strip.py
favorite_language = ' python '
favorite_language = favorite_language.rstrip()
print(favorite_language)
Output:
python
So interactive interpreters(REPL) is for shorter code testing where you see result immediately.
Write real code there is no >>> and have use print() to show the result.
Run Python 3 on Sublime Text (Mac)
As mention before you don't have to Sublime Text even if that what author use.


RE: things that work in terminal mode but not in sublime mode - alok - Aug-11-2021

I do see the same results you see "snippsat". In terminal mode & Sublime text mode.
That is what I don't understand, in the terminal mode on line 3 the results show the right apostrophe moves left by one, because of .rstript() in line 2.
But in the Sublime Text mode ,after using print both apostrophes are gone in the output, because of .rstript(), in line 2.
How come in Subline text mode, the output dosen't shift by one on the rightside apstrophe to the left like in terminal mode ? Instead it gets rid of both apostrophes?

Other question, what do you recommend instead of using Sublime text?

Thanks for your help, Al


RE: things that work in terminal mode but not in sublime mode - snippsat - Aug-11-2021

print() will not show apostrophe.
So if doing this will see nothing,but it still working as left space is gone.
favorite_language = ' python '
favorite_language = favorite_language.lstrip()
print(favorite_language)
Output:
python
favorite_language = ' python '
favorite_language = favorite_language.lstrip()
print(favorite_language)
# Using repr will see all,same as see in interactive interpreter
print(repr(favorite_language))
Output:
python 'python '
alok Wrote:Other question, what do you recommend instead of using Sublime text?
I like VS Code(Free) unlike Sublime text(have to pay to get all features),have a tutorial here.