Python Forum
call an instance of a class in the interactive
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
call an instance of a class in the interactive
#1
hello,
I have created a class 'User':
class User:
      def __init__(self, name, gender, age):
            self.name = name
            self.gender = gender
            self.age = age
            
      def __call__(self, name, gender, age):
            print(name)
            print(gender)
            print(age)
      

user1 = User('dany wasser', 'gender: male', 21)
I put this class in a file called saty.py
then I imported the file 'saty.py' in the interactive mode of the interpreter by:
import saty
the file was successfully imported.
now I want to call the single instance of this class 'user1' with all its attributes into the interactive mode of the interpreter. how can I do this?
>>> print ... ?

thanks in advance
Reply


Messages In This Thread
call an instance of a class in the interactive - by nzcan - Aug-23-2018, 05:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how can I test this interactive calculator using pytest medveeee 4 1,878 Dec-18-2022, 06:13 PM
Last Post: ndc85430
  Please, how do I call the method inside this class Emekadavid 1 1,651 Jun-26-2020, 01:26 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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