On Aug 11, 3:08 pm, Robert Dailey <rcdai...@gmail.com> wrote: > Hey guys. Being a C++ programmer, I like to keep variable definitions > close to the location in which they will be used. This improves > readability in many ways. However, when I have a multi-line string > definition at function level scope, things get tricky because of the > indents. In this case indents are serving two purposes: For syntax and > actual text output. The tabs for function scope should not be included > in the contents of the string. Below is the code I am trying to > improve. Notice how it looks ugly/unreadable because of the way the > string contents are shifted all the way to the left edge of the > document. This breaks the flow of scope. Would you guys solve this > problem by moving failMsg into global scope? Perhaps through some > other type of syntax? > > Help is appreciated! > > def RunCommand( commandList ): > commandString = > print( 'Running Command:', ) > cmd = subprocess.Popen( commandList ) > returnCode = cmd.wait() > if returnCode: > failMsg = '''\ > ************************************************* > The following command returned exit code [{:#x}]. > This represents failure of some form. Please review > the command output for more details on the issue. > ------------ > {} > ************************************************* > ''' > commandString = ' '.join( commandList ) > raise CommandFailure( failMsg.format( returnCode, > commandString ) )
And yes, I recognize there are syntax errors. Ignore those for now. -- http://mail.python.org/mailman/listinfo/python-list