"예상되는 들여 블록"오류가?

수't 왜 python 제"들여쓰기 예상 블록"오류가?

""" This module prints all the items within a list"""
def print_lol(the_list):
""" The following for loop iterates over every item in the list and checks whether
the list item is another list or not. in case the list item is another list it recalls the function else it prints the ist item"""

    for each_item in the_list:
        if isinstance(each_item, list):
            print_lol(each_item)
        else:
            print(each_item)
질문에 대한 의견 (6)
해결책

이 있을 들여쓰기 docstring 후 함수 정의가 있(line3,4):

def print_lol(the_list):
"""this doesn't works"""
    print 'Ain't happening'

들여쓰기:

def print_lol(the_list):
    """this works!"""
    print 'Aaaand it's happening'

또는 사용할 수 있는#의견을 대신:

def print_lol(the_list):
#this works, too!
    print 'Hohoho'

또한,당신은 당신이 볼 수 있는[PEP257](http://www.python.org/dev/peps/pep-0257/#handling-docstring-indentation 행)에 대한 docstrings.

Hope this helps!

해설 (1)

또한 경험을 예를 들어:

이 코드를 작동하고 의도한 블록 오류가 있습니다.

class Foo(models.Model):
title = models.CharField(max_length=200)
body = models.TextField()
pub_date = models.DateTimeField('date published')
likes = models.IntegerField()

def __unicode__(self):
return self.title

그러나 때 tab 키를 누르기 전에 입력하는 반 자체입니다.제목 문의 코드 작동합니다.

class Foo(models.Model):
title = models.CharField(max_length=200)
body = models.TextField()
pub_date = models.DateTimeField('date published')
likes = models.IntegerField()

def __unicode__(self):
    return self.title

희망하고,다른 사람을 도움이 될 것입니다.

해설 (0)