Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why this compile error?

2 views
Skip to first unread message

Jimbo

unread,
Mar 19, 2010, 5:37:35 AM3/19/10
to
Hello

Can you help me figure out why I am getting this compile error with my
program. The error occurs right at the bottom of my code & I have
commented where it occurs.

The error is:
[QUOTE]Expected an indented block[/QUOTE]

[CODE]"""
*Stock Data Builder*
Algorithm:
- Search website for stock
- Get website HTML source code
- Search code for target stock data(price,dividends)
- Add data to text file
"""

import sys

# Functions
def getSource(URL, sourceBuffer):
""" Retrieve HTML source code from websitr URL &
save in sourceBuffer """

return sourceBuffer

def getData(targetData, dataBuffer):
""" Searches the string dataBuffer for the occurence of target
data & returns that whole line """

def writeToFile(textFile, dataBuffer):
""" Writes data in string dataBuffer to text file """

# CHANGE this to try except to catch errors
fileT = open(textFile,'a')
fileT.write(dataBuffer)
return True; # function succeeded

def writeToFile(textFile, dataList):
""" Writes data in List dataList to text file """

# CHANGE this to try except to catch errors
fileT = open(textFile,'a')

for element in dataList:
fileT.write(element)
return True; # function succeeded

# Main program loop
def main():
programEnd = False;

while (programEnd == False):
#ERROR HERE?? - Error="Expected an indented block"
main()[/CODE]

Bruno Desthuilliers

unread,
Mar 19, 2010, 6:04:11 AM3/19/10
to
Jimbo a écrit :

> Hello
>
> Can you help me figure out why I am getting this compile error with my
> program. The error occurs right at the bottom of my code & I have
> commented where it occurs.
>
> The error is:
> [QUOTE]Expected an indented block[/QUOTE]
>
> [CODE]
(snip)

> # Main program loop
> def main():
> programEnd = False;
>
> while (programEnd == False):
> #ERROR HERE?? - Error="Expected an indented block"

Indeed. You *need* a stamement in the while block. If you want a noop,
then use the 'pass' statement:

while programEnd == False:
pass


But note that as-is, this will go into an infinite loop.

Ulrich Eckhardt

unread,
Mar 19, 2010, 6:11:18 AM3/19/10
to
Jimbo wrote:
> Can you help me figure out why I am getting this compile error with my
> program. The error occurs right at the bottom of my code & I have
> commented where it occurs.
[...]

> def main():
> programEnd = False;
>
> while (programEnd == False):
> #ERROR HERE?? - Error="Expected an indented block"
> main()[/CODE]

Was the comment there before or not? In any case, I believe a comment
doesn't qualify as indented block, if you want to leave the block empty
use 'pass' instead. Also, make sure you don't mix tabs and spaces, which is
also a popular way to confuse Python.

BTW: "while" doesn't need brackets, that's a C-ism. ;)

Cheers!

Uli

--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

0 new messages