java - python - another class inside constructor -
i'm new python , i'm having hard time understanding how can following in python (e.g how in java)
class person{ private string name; private address address; public person(string xyz, address a) { this.name = xyz; this.address = a; } .... }
i don’t know why think there class inside constructor, above java in python:
class person (object): def __init__ (self, xyz, a): self.name = xyz self.address = as dynamically typed language, python not need know types when code compiles. instead, dynamically creates objects, , adds properties whenever needed. allows not add instance fields in initializer not declared before, allows add things after object created:
x = person("poke", "my address") x.phonenumber = "012345679"
Comments
Post a Comment