Python Forum
class program no output under python 3.5.1
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
Reply
#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]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Some help with my first python class and importing ....im making a lidar program jttolleson 7 1,145 Jul-28-2023, 08:34 AM
Last Post: jttolleson
  My code displays too much output when importing class from a module lil_e 4 1,103 Oct-22-2022, 12:56 AM
Last Post: Larz60+
  waiting for barcode scanner output, while main program continues to run lightframe109 3 4,585 Sep-03-2020, 02:19 PM
Last Post: DeaD_EyE
  How to get program output from subprocess.Popen? glestwid 1 2,335 Aug-19-2020, 05:44 AM
Last Post: buran
  how can we record a video file from our program output (moving object) Zhaleh 0 1,781 Aug-03-2020, 02:47 PM
Last Post: Zhaleh
  How do I stop this fast factorization program from printing beyond the 3rd output? Pleiades 6 3,780 Dec-07-2019, 08:43 PM
Last Post: Pleiades
  [Python Class] save method output to global file/list Vijay 3 4,985 Dec-23-2017, 03:20 AM
Last Post: Vijay
  Converting c++ class to python class panoss 12 11,709 Jul-23-2017, 01:16 PM
Last Post: Larz60+
  input-external program-output baolevani 2 3,878 Mar-27-2017, 04:34 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020