Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Sublime3 unexpected indent trickle affect

Greetings,
I was curious if you guys had any tips about a Sublime setup when it comes to Python? Sometimes when I go run my code I get an unexpected indent error. It happens ... so I go check statements, tabs, and spaces.


The issue is when I 'fix' one line of code, the spaces or whatever, it affects the next line. I fix that next line, and it happens to the next line! It is quite frustrating. It doesn't matter if I start corrections from the top or below. I can select the text and see the spaces and tabs. They change as I make the corrections to other lines.
No tips about Sublime setup, but launching the script by:
Code
python -tt script.py

should solve the problem.
Are you mixing tabs and spaces? Python can generally handle either, but not both.
Hi, i had this problem also, but i found the easiest trick for it.

In Sublime click, View->Indentation->Convert indentations to Tabs
(Oct 25, 2016 10:05 PM)SpacePupper Wrote:  Are you mixing tabs and spaces? Python can generally handle either, but not both.

Not directly. I strictly use tabs, but somehow spaces get in there.

(Oct 26, 2016 04:59 AM)bytez Wrote:  Hi, i had this problem also, but i found the easiest trick for it.

In Sublime click, View->Indentation->Convert indentations to Tabs

Thanks. I think that'll help a bit. But I think it maybe more that my tab size was 4. I have to manually restructure about 10 scripts and thousands of lines of code just to fix the spacing. Find a replace doesn't fully do the job.
(Oct 26, 2016 11:34 AM)datguy.dev Wrote:  Not directly. I strictly use tabs, but somehow spaces get in there.


Thanks. I think that'll help a bit. But I think it maybe more that my tab size was 4. I have to manually restructure about 10 scripts and thousands of lines of code just to fix the spacing. Find a replace doesn't fully do the job.

I had the problem cause i copy pasted my script from pycharm, and the fix works all the time, it converts every line so i dont have to do it manually :)

How come you have to do manually when it does it auto? :D
(Oct 26, 2016 01:18 PM)bytez Wrote:  I had the problem cause i copy pasted my script from pycharm, and the fix works all the time, it converts every line so i dont have to do it manually :)

How come you have to do manually when it does it auto? :D

The automatic indentation function you stated previously isn't correctly fixing all the indents. It'll randomly leave 4 spaces, in other areas in doesn't. It breaks statements, nested statements, and thus the flow of a script. So I have to do a logic check as well. meh. . . It is better than nothing.
(Oct 26, 2016 01:29 PM)datguy.dev Wrote:  The automatic indentation function you stated previously isn't correctly fixing all the indents. It'll randomly leave 4 spaces, in other areas in doesn't. It breaks statements, nested statements, and thus the flow of a script. So I have to do a logic check as well. meh. . . It is better than nothing.

Oh wierd, it works alright for me, but i dont have like 500 lines programs :D
(Oct 26, 2016 02:07 PM)bytez Wrote:  Oh wierd, it works alright for me, but i dont have like 500 lines programs :D

Honestly, it is just messing up because of the current spacing issues in scripts. This is a good learning experience for me to setup before starting. Thanks for the suggestion. It saved me quite some time. 👍


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by simmerJul 30, 2021 10:08 AM 7 232 Jul 30, 2021 10:08 AM
Last Post: simmer
[Python] by TreasuretrioAug 2, 2020 08:01 PM 2 152 Aug 2, 2020 08:01 PM
Last Post: Treasuretrio
[Shell] by ExsanityNov 30, 2016 05:34 PM 4 220 Nov 30, 2016 05:34 PM
Last Post: b00st3d