Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Composition question
#4
Hi, thanks, I implemented __str__, and now it works lik a charm.

class Folder:
    _path = ''
    _files = []

    def __init__(self, path):
        if not os.path.exists(path):
            message = "folder does not exist"
            raise TypeError(message)

        self.path = path

    def __str__(self):
        return self.path

(Jan-07-2020, 11:06 AM)buran Wrote: Just to note that defining THAT much classes is not necessary, e.g. Source and Destination classes are virtually the same and almost the same as Folder

I know that, but it's just a composition testing. In the end there wont be 3 classes. Smile
Reply


Messages In This Thread
Composition question - by kerzol81 - Jan-07-2020, 10:00 AM
RE: Composition question - by buran - Jan-07-2020, 10:21 AM
RE: Composition question - by buran - Jan-07-2020, 11:06 AM
RE: Composition question - by kerzol81 - Jan-07-2020, 11:30 AM

Forum Jump:

User Panel Messages

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