Search code examples
pythonraspberry-piadobe-brackets

Python code tabs not recognised between windows and linux


I am using a windows computer to write some python code and I upload it to my raspberry.

I use notepad++ on my computer and adobe brackets. In Adobe brackets, when I do 1 tab, it aligns it so the indentation is correct for python (for example, I hit tab only once and it is aligning as if it was 4 tabs). In notepad++ I can see 4 tabs.

But when I upload it to my raspberry which is linux and I use nano to see the file, I only see 1 tab instead of 4. That gives me of course a lot of errors.

Thanks if you can help,

John.


Solution

  • Hard tabs are interpreted as different characters on windows and linux. You should always use spaces for Python. You can use reindent.py to fix it on Windows and then it should work on both. This script should be located in your Python install directory. Usage is:

    reindent.py badcode.py