Skip to main content
Post Reopened by bruno desthuilliers python
3
Link
Moses Koledoye
  • 78.8k
  • 8
  • 139
  • 141
edited tags; edited title
Link
cs95
  • 406k
  • 106
  • 744
  • 795

method and sub-method Chaining instance methods in python

Post Closed as "Duplicate" by Moses Koledoye python
Source Link
dkmatt0
  • 243
  • 2
  • 8

method and sub-method in python

I would like create a class in python with method and sub-method.

Example what I want to do :

foo = Foo()
foo.playlist('my playlist').add('i_add_a_track_in_"my playlist".ogg')
foo.playlist('my playlist').delete('i_remove_this_track.ogg')

I have this code for now :

class Foo(object):
    def playlist(self, name):
        pass #my function...
    def add(self, track):
        pass #adding track
    def delete(self, track):
        pass #delete track

Please help me, I don't know how i can do it.

Thank you