how to use arguments of classes - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: how to use arguments of classes (/thread-22190.html) |
how to use arguments of classes - ati68 - Nov-03-2019 Hi I'm new to python I am writing a code and i imported a module that has many classes and functions I wanted to know how can i access to arguments in those classes/functions Or just i can access to name of classes and functions in my code not arguments that have been defined in functions ? I would be grateful if someone clarify me on this RE: how to use arguments of classes - Yoriz - Nov-03-2019 Can you give an example code of what you are trying to access? RE: how to use arguments of classes - ati68 - Nov-03-2019 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? RE: how to use arguments of classes - buran - Nov-03-2019 first of all you can and should read the docs. you can use dir() function to get and print all available classes, functions, etc. also for more detailed info - you can use help() function e.g. for third-party requests module, but you can use the same for any module import requests print(dir(requests)) print(help(requests.Session)) RE: how to use arguments of classes - AlekseyPython - Nov-03-2019 (Nov-03-2019, 09:11 AM)ati68 Wrote: for example: def my_func(): kisa = cat('Murzik') kisa.add_trick('jumping') kisa.add_trick('running') for current_trick in kisa.trick: print(current_trick) |