SublimeREPL에서 일부 Python 명령을 평가하려고하지만 모든 새로운 명령으로 인해 IndentationError가 발생합니다. 한 번에 한 줄씩 보내면 코드가 작동합니다. 나는 일부 라인 주석 문자를 넣어 경우 여기 Python 들여 쓰기 오류 : SublimeREPL을 사용하는 숭고한 텍스트 2
는 ... 그러나 로 평가class Array(object):
def __init__(self, length = 0, baseIndex = 0):
assert(length >= 0)
self._data = [0 for i in range(length)]
self._baseIndex = baseIndex
def __copy__(self):
result = Array(len(self._data))
for i, datum in enumerate(self._data):
result._data[i] = datum
result._baseIndex = self._baseIndex
return result
def __len__(self):
return len(self._data)
...
IndentationError: unexpected indent
>>> class Array(object):
... def __init__(self, length = 0, baseIndex = 0):
... assert(length >= 0)
... self._data = [0 for i in range(length)]
... self._baseIndex = baseIndex
...
>>> def __copy__(self):
File "<stdin>", line 1
def __copy__(self):
^
IndentationError: unexpected indent
>>> result = Array(len(self._data))
File "<stdin>", line 1
result = Array(len(self._data))
^
IndentationError: unexpected indent
>>> for i, datum in enumerate(self._data):
File "<stdin>", line 1
for i, datum in enumerate(self._data):
^
IndentationError: unexpected indent
>>> result._data[i] = datum
File "<stdin>", line 1
result._data[i] = datum
^
IndentationError: unexpected indent
>>> result._baseIndex = self._baseIndex
File "<stdin>", line 1
result._baseIndex = self._baseIndex
^
IndentationError: unexpected indent
>>> return result
File "<stdin>", line 1
return result
^
IndentationError: unexpected indent
>>>
>>> def __len__(self):
File "<stdin>", line 1
def __len__(self):
^
IndentationError: unexpected indent
>>> return len(self._data)
File "<stdin>", line 1
return len(self._data)
^
IndentationError: unexpected indent
예에서 시도이다는 제외하고 잘 작동 각 줄 앞에 후행 "... ... ... ..."에 대해
class Array(object):
def __init__(self, length = 0, baseIndex = 0):
assert(length >= 0)
self._data = [0 for i in range(length)]
self._baseIndex = baseIndex
#
def __copy__(self):
result = Array(len(self._data))
for i, datum in enumerate(self._data):
result._data[i] = datum
result._baseIndex = self._baseIndex
return result
#
def __len__(self):
return len(self._data)
#
보내진 후 나는 REPL 창을 클릭하고 "... ... ... ..."이라는 줄을 입력하여 평가를 받으십시오.
>>> class Array(object):
def __init__(self, length = 0, baseIndex = 0):
assert(length >= 0)
self._data = [0 for i in range(length)]
self._baseIndex = baseIndex
#
def __copy__(self):
result = Array(len(self._data))
for i, datum in enumerate(self._data):
result._data[i] = datum
result._baseIndex = self._baseIndex
return result
#
def __len__(self):
return len(self._data)
#
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
나는 매우 단순한 것이 누락되면 사과드립니다. 나는이 답을 어디에서나 찾아 보았습니다.