S
Scott Brady Drummonds
Hi, everyone,
I have a bug in a script of several hundred lines of code that I cannot
figure out. I have attempted (unsuccessfully) to duplicate this problem in
a smaller script that I can post here but have been unsuccessful. As such,
I'm posting code snippets here in the hopes that someone recognizes a very
basic mistake I've made and can straighten me out.
First, the portion of my text file that executes my code:
<quote>
if __name__ == '__main__':
if len(sys.argv) != 2:
print('usage: %s <config_file>' % sys.argv[0])
sys.exit()
main(sys.argv[1])
</quote>
Here are the first few lines of my 'main' procedure:
<quote>
def main(fileName):
print('DEBUG: begin main procedure')
...
</quote>
And here is the part that is causing problems:
<quote>
# 'keys' is a list of integers returned from dict.keys()
for cycle in keys:
if key in skipList:
print ('skipping %d/%d' % (cycle, cycleMap[cycle]))
continue
try:
print('DEBUG: advancing both simulators to %d' % cycle)
procedureThatCouldRaiseEOFError()
except EOFError:
print('DEBUG: encountered EOFError; breaking loop')
break
print('DEBUG: All cycles processed')
</quote>
Here's what I can't figure out. I'm seeing the following text generated
during this script's execution:
<quote>
DEBUG: advancing both simulators to 20178
DEBUG: encountered EOFError; breaking loop
DEBUG: begin main procedure
</quote>
How is it possible that the call to 'break' is seemingly being replaced with
a call to 'main'?
Thanks!
Scott
I have a bug in a script of several hundred lines of code that I cannot
figure out. I have attempted (unsuccessfully) to duplicate this problem in
a smaller script that I can post here but have been unsuccessful. As such,
I'm posting code snippets here in the hopes that someone recognizes a very
basic mistake I've made and can straighten me out.
First, the portion of my text file that executes my code:
<quote>
if __name__ == '__main__':
if len(sys.argv) != 2:
print('usage: %s <config_file>' % sys.argv[0])
sys.exit()
main(sys.argv[1])
</quote>
Here are the first few lines of my 'main' procedure:
<quote>
def main(fileName):
print('DEBUG: begin main procedure')
...
</quote>
And here is the part that is causing problems:
<quote>
# 'keys' is a list of integers returned from dict.keys()
for cycle in keys:
if key in skipList:
print ('skipping %d/%d' % (cycle, cycleMap[cycle]))
continue
try:
print('DEBUG: advancing both simulators to %d' % cycle)
procedureThatCouldRaiseEOFError()
except EOFError:
print('DEBUG: encountered EOFError; breaking loop')
break
print('DEBUG: All cycles processed')
</quote>
Here's what I can't figure out. I'm seeing the following text generated
during this script's execution:
<quote>
DEBUG: advancing both simulators to 20178
DEBUG: encountered EOFError; breaking loop
DEBUG: begin main procedure
</quote>
How is it possible that the call to 'break' is seemingly being replaced with
a call to 'main'?
Thanks!
Scott