D
D
Di Ma2017-05-27 23:12:15
Python
Di Ma, 2017-05-27 23:12:15

Python. Why does the number of tabs per line change when reading a file?

Hello!
I'm trying to write a plugin for Sublime-text. Unfortunately I don't know Python.
Here is what I have:

import os
import sublime
import sublime_plugin

class testPluginCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        path = os.path.dirname(os.path.realpath(__file__))
        file = open(path + '/text.pattern', 'r')

        result = ''
        for line in file:
            result += line
            # result += line.expandtabs(4) # не помогает

        # помещает полученную строку в редактор
        self.view.run_command("insert", {"characters": result})

File text.pattern
29fc52b5ad98411ca21c973b9e8c73a7.jpg
A is inserted into the editor into this:
21c6b6c826f140a4b983a176441176ff.jpg
Reading the entire file result= open(path + '/text.pattern', 'r').read()produces the same result.
Please tell me what can be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Di Ma, 2017-05-28
@dimentimor

Issue resolved. It's all about sublime settings.
Should have been exposed"auto_indent": false,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question