Sublime Forum

Python reindent problem

#1

I have a problem understanding the behavior of the reindent command with Python code:

I have made a little sample code screenshot to illustrate the problem, but apparently i can’t even upload it on the forum.

So here it is:

[code]
def screenGrab():
box = ()
im = ImageGrab.grab()
im.save(os.getcwd() + ‘\full_snap__’ + str(int(time.time())) + ‘.png’, ‘PNG’)

def main():
screenGrab()

if name == ‘main’:
main()[/code]

This gets built and runs normally. Now, if I use reindent on this piece of code, I get this:

[code]
def screenGrab():
box = ()
im = ImageGrab.grab()
im.save(os.getcwd() + ‘\full_snap__’ + str(int(time.time())) + ‘.png’, ‘PNG’)

def main():
    screenGrab()

    if __name__ == '__main__':
        main()[/code]

I’m not a Python expert but the code after reindent will not be built properly because of the wrong indentation.
I don’t use hard tabs and i have a tab width of 4.
What am I doing wrong? Thanks

0 Likes