Python Forum
Python - List - Int List
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python - List - Int List
#3
class IntList(list):
       def __init__(self):
          self.internal_list = []
       def append(self, elem):
           if not isinstance(elem, int):
               raise TypeError('x musi byt typu Integer')
           self.internal_list[len(self.internal_list):] = [elem]
       def getList(self):
           return self.internal_list
I have that, after a long time :D but I don't know if is the right implementation. Maybe I have problem with print some list. Should I add some others methods ?
Reply


Messages In This Thread
Python - List - Int List - by sophi - Apr-20-2022, 11:24 AM
RE: Python - List - Int List - by Larz60+ - Apr-20-2022, 01:11 PM
RE: Python - List - Int List - by sophi - Apr-20-2022, 01:16 PM
RE: Python - List - Int List - by deanhystad - Apr-20-2022, 05:03 PM
RE: Python - List - Int List - by sophi - Apr-20-2022, 06:59 PM
RE: Python - List - Int List - by deanhystad - Apr-20-2022, 10:02 PM
RE: Python - List - Int List - by sophi - Apr-21-2022, 07:35 PM
RE: Python - List - Int List - by deanhystad - Apr-21-2022, 07:52 PM
RE: Python - List - Int List - by sophi - Apr-21-2022, 07:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to parse and group hierarchical list items from an unindented string in Python? ann23fr 1 429 May-23-2024, 05:39 AM
Last Post: Pedroski55
  how to reverse a list and store in another list in python SuperNinja3I3 6 3,448 Aug-14-2022, 06:36 PM
Last Post: DeaD_EyE
  question on list in Python spalisetty06 1 2,105 Jun-30-2020, 09:03 AM
Last Post: pyzyx3qwerty
  Python list exercize ESTOUR 3 2,008 May-23-2020, 11:10 PM
Last Post: ESTOUR
  Python Adding +1 to a list item cointained in a dict ElReyZero 1 2,131 Apr-30-2020, 05:12 AM
Last Post: deanhystad
  Check if a list exists in given list of lists Daniel94 2 2,321 Apr-07-2020, 04:54 PM
Last Post: deanhystad
  list of strings to list of float undoredo 3 2,766 Feb-19-2020, 08:51 AM
Last Post: undoredo
  arrays sum list unsupported operand type(s) for +=: 'int' and 'list' DariusCG 7 4,358 Oct-20-2019, 06:24 PM
Last Post: Larz60+
  have homework to add a list to a list using append. celtickodiak 2 2,086 Oct-11-2019, 12:35 PM
Last Post: ibreeden
  Search character from 2d list to 2d list AHK2019 3 2,558 Sep-25-2019, 08:14 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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