Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 class program no output under python 3.5.1
#1
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
Larz60+ wrote Jan-22-2019, 10:41 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

I have fixed for you this time, please use code tags on future posts.
Also please note indentation should be 4 spaces per level (PEP8)
Quote
#2
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]
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How do I stop this fast factorization program from printing beyond the 3rd output? Pleiades 6 295 Dec-07-2019, 08:43 PM
Last Post: Pleiades
  [Python Class] save method output to global file/list Vijay 3 1,583 Dec-23-2017, 03:20 AM
Last Post: Vijay
  Converting c++ class to python class panoss 12 4,827 Jul-23-2017, 01:16 PM
Last Post: Larz60+
  input-external program-output baolevani 2 1,379 Mar-27-2017, 04:34 PM
Last Post: nilamo

Forum Jump:


Users browsing this thread: 1 Guest(s)