quick python question

foothead

Omnicide now.
Messages
10,027
Location
My own personal hell
I have this simple python program I wrote a while back to help study that basically does flashcards, but I can't do more than about 20 because I get an error that I have too many statically nested blocks. Exactly how many can I have? I havent ever heard of python having a limit. All they are being used to do is to hold all the questions and potential answers, etc. Can someone help me to maybe put them as like a .txt or something? I'm a total n00b at programming. thx.
 
I have this simple python program I wrote a while back to help study that basically does flashcards, but I can't do more than about 20 because I get an error that I have too many statically nested blocks. Exactly how many can I have?
From looking around a bit it seems that the answer is indeed 20. Any more and python won't like it!

However, if you find yourself using this many nested blocks something has gone seriously wrong in your design process - I end up uncomfortable if I have to use more than 3 or 4 nested blocks, any more than that and it's time for a rethink on the best way to do things. 20 is rather ridiculous!

I can't say how best to approach the problem without seeing your code, but it sounds like the "nice" way of doing this would be to farm them out into an XML file and then read them in from there. As a general design principle the questions / answers shouldn't really be hardcoded anyway.
 
There are ways to read and write text files, maybe you could do it with that.

line = 1
questions = []
file = open("questions.txt","r")
while line <= file:
questions.append(file.read(line))
line += 1
file.close()
line = 1
answers = []
file = open("answers.txt","r")
while line <= file:
answers.append(file.read(line))
line += 1
file.close()

that may help...
 
Back
Top Bottom