in Education by
I'm learning oop in python after learning it in Java. It happens that i'm trying to create an array from my class Person which will contain Person objects within. When I create a single object Intellisense shows the methods available: class Person: name: str def set_name(self, name: str): self.name = name person1 = Person() person1.set_name("John") #<--- Here it shows the custom method i made. But when I make an array with Person objects within it and I try to use the methods calling the object from the array the methods just doesn't appear. class Person: name: str def set_name(self, name: str): self.name = name people = [] for i in range (5): people.append(Person()) people[0].set_name("John") #<---- After writting the dot the methods are empty, #and when written it doesn't have the "color code" it should have. Does anyone know why is this happening? :C JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can add type hint for people. class Person: name: str def set_name(self, name: str): self.name = name people = [] for i in range (5): people.append(Person()) people:list[Person] # add type hint here people[0].set_name("John")

Related questions

0 votes
    I have a Visual Studio online Team Project with a repository. I have been using this with VS 2013 for a ... and doing clone again? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    In Visual Studio Code, is there any way to have new tabs open to the right of all existing tabs? ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    In Visual Studio Code, is there any way to have new tabs open to the right of all existing tabs? ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    Which of these methods can be used to obtain a static array from an ArrayList object? (a) Array() ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    A gitlab-runner configuration script .gitlab-ci.yml, for execution in the Powershell: windows: tags: - ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    A couple months ago I did a project in C++ with Visual Studio that I needed pthreads for, so I ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I am using Team Services on domain visualstudio.com and I need to delete one project, I found out that I ... don't have privileges. Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    I get data from socket io this JSON every 10 sec.. data { "nr": "1" } data { "nr": " ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    I'm working on VS 2005 and something has gone wrong on my machine. Suddenly, out of the blue, I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I have tried many solution online but I am unable to fix. First off all i check in bin and it ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    What is the .vs folder used for exactly? It gets created at the base folder of my solution. I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I'm trying to implement continuous integration and continuous deployment to my DEV Azure App Service. I'm ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    Visual Studio Code has option to connect to jupyter notebook. When it's done I can execute my script ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I am a complete beginner in allegro and i just installed allegro correctly and this is my code(my first ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 22, 2022 in Education by JackTerrance
0 votes
    I'm trying to install MySQL for Visual Studio 1.2.8 and Connector/NET 8.0.13 via MySQL Installer ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
...