Python Constructor not showing anything on IDE -


trying create class constructor reason im failing misarably when testing..

class person(object):     name=""     age=0     city=""      def __init__ (self,name,age,city):         self.name=name         self.age=age         self.city=city              #just testing     def addperson(person):         person1 = person()         person1.name="test"         person1.age=1         person1.city="here"         print(person1) 

process finished exit code 0. nothing happening. know basic maybe im not seeing here. ?

if that's code, you're not instantiating object. add code ( on left, not in class):

p = person("fernando", 99, "city") print(p.age) print(p.name) print(p.city) 

and output should be:

99 fernando city 

you defined class, doesn't until create instance of shown.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -