Python Forum

Full Version: class program no output under python 3.5.1
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
my python profram is as follows:
class logent(object):
 def __init__(self, s):
  self.line=s
  self.info=s.split('',5)
  
 def printline(self):
  print(self.line)
  for entry in self.info:
    print(entry)
  print()
  
  s1 = 'Mar 26 15:17:01 Steven CRON[13135]'
  lo=logent(s1)
  lo.printline()
but there is no output and no warning message, what's the wrong with this program
class logent(object):
    def __init__(self, s):
        self.line = s
        self.info = s.split()
    
    def printline(self):
        print(self.line)
        for entry in self.info:
            print(entry)
        print()

def main():    
    s1 = 'Mar 26 15:17:01 Steven CRON[13135]'
    lo=logent(s1)
    lo.printline()

if __name__ == '__main__':
    main()
output:
Output:
Mar 26 15:17:01 Steven CRON[13135] Mar 26 15:17:01 Steven CRON[13135]