views:

50

answers:

1

how can initialize empty objects in python ?

I need to initialize my class members (for examples tk.frames, vtk visualizations etc)

thanks

+3  A: 

Access the attributes of self in your __init__() method.

class C(object):
  def __init__(self, val):
    self.val = val
Ignacio Vazquez-Abrams
@Ignacio Vazquez-Abrams So, I don't need to add members to the class.. just declare them inside the constructor for the first time
Patrick
Members added to the class directly become class attributes, and are shared across all instances of the class. This is rarely what is wanted for attributes other than methods.
Ignacio Vazquez-Abrams