Nested if and expected an indent block

Pierre Barbier de Reuille p.barbierdereuille at free.fr
Mon Aug 14 04:42:47 EDT 2006


kagard at gmail.com wrote:
> Simon Forman wrote:
>>> I got rid of the triple quote string at the start of the function, and
>>> that cleared up the problem, though I don't know why.
>>>
>> Ah, yes. The docstring for a function (or at least its first
>> triple-quote) must be indented to the same degree as its statements.
>> (If you're using IDLE it should have indented it for you when you hit
>> return after the def statement.)
>>
>> HTH,
>> ~Simon
> 
> Hi Simon:
> 
> Thanks. I code in VB / VBA, and use indented structure, but it's not
> enforced they way it is in Python - still getting used to that. Also, I
> got goofed up editing some of the code in VIM, indenting with tabs, and
> then switching to IDLE, with space indentation. Whoops...
> 
> Thanks for all the help everyone, my first Python program is now
> working!
> 
> Keith
> 

Tips: if you're coding with VIM, put "set expandtab" in your config
file. That way, each tab will be expanded into the corresponding number
of spaces ... Whatever the language, I find it always a bad idea to mix
spaces and tabs, and I prefer spaces ...

Pierre



More information about the Python-list mailing list