Python Forum
TypeError: __str__ returned non-string error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: __str__ returned non-string error
#2
class srvinfo(object):

def __init__(self,id,name=None,comp=None):
self.id=id
self.name=name

self.comp=comp

def change_usr(self,id,name,comp):
self.id=id
self.name=name
self.comp=comp

def __str__(self):

return f '{self.id} {self.name} : {self.comp}' 
s=srvinfo(1021)
print(s)
s.change_usr(1022,'Jeffery','Microsoft')
print(s)
Reply


Messages In This Thread
RE: TypeError: __str__ returned non-string error - by jolinchewjb - Jan-23-2019, 08:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  error in class: TypeError: 'str' object is not callable akbarza 2 652 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  How to access values returned from inquirer cspower 6 1,014 Dec-26-2023, 09:34 PM
Last Post: cspower
  boto3 - Error - TypeError: string indices must be integers kpatil 7 1,468 Jun-09-2023, 06:56 PM
Last Post: kpatil
  "TypeError: string indices must be integers, not 'str'" while not using any indices bul1t 2 2,198 Feb-11-2023, 07:03 PM
Last Post: deanhystad
  Error TypeError: output_type_handler() takes 2 positional arguments but 6 were given paulo79 1 2,076 Oct-17-2022, 06:29 PM
Last Post: paulo79
  TypeError: string indices must be integers JonWayn 12 3,691 Aug-31-2022, 03:29 PM
Last Post: deanhystad
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 5,052 Jul-01-2022, 01:23 PM
Last Post: deanhystad
  "<class 'typeerror'>: don't know how to convert" error GiggsB 3 3,540 Feb-28-2022, 06:45 PM
Last Post: GiggsB
  SQLAlchemy Object Missing when Null is returned Personne 1 1,835 Feb-19-2022, 02:50 AM
Last Post: Larz60+
  TypeError: not enough arguments for format string MaartenRo 6 3,073 Jan-09-2022, 06:46 PM
Last Post: ibreeden

Forum Jump:

User Panel Messages

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