Running script in __main__ shows no output in IDLE
Scott David Daniels
scott.daniels at acm.org
Mon May 22 19:57:56 EDT 2006
More information about the Python-list mailing list
Mon May 22 19:57:56 EDT 2006
- Previous message (by thread): File attributes
- Next message (by thread): Running script in __main__ shows no output in IDLE
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
heidi.hunter at fantasy-interactive.com wrote: > I just downloaded the most recent (2.4.3) Python and IDLE (1.1.3) to > Windows XP Professional. I'm new to the IDLE environment, so hopefully > someone can tell me what I'm missing here! Below is the code, which I'm > editing within IDLE, and attempting to test with the Run commands. > > I was expecting to see at least see the prints to stdout from the if > __name__ ... statement and main() function, but when I use F5 Run > module I don't see any output or errors. Any suggestions? Does IDLE > still need the executable file statement at the top even if I run it > explicity? > > --------------------------------------------------------------------------------------- > import sys > from xml.sax import ContentHandler, make_parser > from xml.sax.handler import feature_namespaces > > class AuthorHandler(ContentHandler): > # """Converts an author file""" > > def __init__(self,outfilename): > # """Constructor. Takes output file name.""" > self.outfile = "" > self.insertCmd = "INSERT Authors SET " ... Don't comment out those strings, you'll find them more useful in Idle if they are there. > def main(args): > ... > # Parse the file; your handler's methods will get called > parser.parse(args[0]) > > print ah.insertCmd > > if __name__ == "__main__": > print "to main" > main("\\Iceman\propod\flash\xml\webService\XmlData\Authors\Heidi") As someone else said, use both a better string constant and a list, since main looks at "args[0]". If nothing else: main([r"\\Iceman\propod\flash\xml\webService\XmlData\Authors\Heidi"]) To investigate the idle environment, simply add: if __name__ == "__main__": print "to main" main([r"\\Iceman\propod\flash\xml\webService\XmlData\Authors\Heidi"]) else: print 'Sorry, __name was %r, not "__main__".' % __name__ --Scott David Daniels scott.daniels at acm.org
- Previous message (by thread): File attributes
- Next message (by thread): Running script in __main__ shows no output in IDLE
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list