Python Forum
how to use arguments of classes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to use arguments of classes
#5
(Nov-03-2019, 09:11 AM)ati68 Wrote: for example:
class cat:
            def __init__(self,name):
              self.name = name
              self.trick = []
            def add_trick(self,trick):
               self.trick.append(trick)
             
now i imported cat class in my code
i want to know can i use trick argument in my code Or i just can access to cat class and add_trick function
and no access to arguments inside of class/function?

def my_func():
    kisa = cat('Murzik')
    kisa.add_trick('jumping')
    kisa.add_trick('running')

    for current_trick in kisa.trick:
       print(current_trick)
Reply


Messages In This Thread
how to use arguments of classes - by ati68 - Nov-03-2019, 05:13 AM
RE: how to use arguments of classes - by Yoriz - Nov-03-2019, 09:08 AM
RE: how to use arguments of classes - by ati68 - Nov-03-2019, 09:11 AM
RE: how to use arguments of classes - by AlekseyPython - Nov-03-2019, 10:45 AM
RE: how to use arguments of classes - by buran - Nov-03-2019, 09:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using classes? Can I just use classes to structure code? muteboy 5 5,064 Nov-01-2017, 04:20 PM
Last Post: metulburr
  Functions (Arguments Passing,Changing a mutable ,Assignment to Arguments Names) Adelton 2 3,881 Mar-02-2017, 10:23 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

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