How to represent a new part of class in python? -


for example had class this:

class planet(object):     def _init_(self, id = 0, name="", mass = 0)     self.id = id     self.name = name     self.mass = mass 

can write planet earth -

import(whatever) name=earth id=1 mass = 5.97219 × 1024 kg 

or must planet earth written in same way class (sorry bad formatting, code each combined 1 block not separate ones)?

you need create instance of planet , initialize it:

earth = planet() earth.name = "earth" earth.id = id earth.mass = 5.97219 × 1024 kg 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -