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]
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.
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