Slexy.org is shutting down and stopped accepting new Pastes on May 4th, 2021.
Existing Pastes will stop being available on or after May 10th, 2021.
Author: Not specified Language: text
Description: Not specified Timestamp: 2017-08-03 22:51:57 +0000
View raw paste Reply
  1. #!py
  2. import sys
  3. string1 = 'A      B         C'
  4. string2 = 'D      E         F'
  5. string3 = 'THIS   THAT                   THEN'
  6.  
  7. DEBUG = 0
  8.  
  9. character_columns = {0:'Undefined', 1:'Undefined', 2:'Undefined'}
  10. for string in string1, string2, string3:
  11.   column = 0
  12.   iteration = 0
  13.   characters = {}
  14.   wordList = string.split()
  15.   for eachWord in wordList:
  16.     characters[iteration] = string.find(eachWord)
  17.     if character_columns[iteration] == 'Undefined':
  18.       character_columns[iteration] = characters[iteration]
  19.     iteration += 1
  20.   if characters != character_columns:
  21.     print >> sys.stderr, "CRITICAL: when attempting to match string columns for string: '" + string + "' on line " + str(iteration - 1)
  22.     #print >> sys.stderr, "Columns aligned as: ", characters, ' Expected: ', character_columns
  23.     for counter in 0, 1, 2:
  24.       if characters[counter] != character_columns[counter]:
  25.         print >> sys.stderr, "Column " + str(counter + 1) + " was aligned at:", characters[counter]
  26.         print >> sys.stderr, "               Expected:", character_columns[counter]
  27.     sys.exit(2)
View raw paste Reply