These are chat archives for ipython/ipython

15th
Feb 2015
Sylvain Corlay
@SylvainCorlay
Feb 15 2015 04:36
I like pep8 though
I wish C++ had something like this
Sylvain Corlay
@SylvainCorlay
Feb 15 2015 05:59
In the documentation of traitlets, you adopt the notation [ default foo ] to specify the default value. Is it something that is later interpreted by sphinx, or just a local convention?
Min RK
@minrk
Feb 15 2015 06:02
local convention, I think
Sylvain Corlay
@SylvainCorlay
Feb 15 2015 19:13
@jdfreder do you plan on opening a PR for your add_trait helper function?
Sylvain Corlay
@SylvainCorlay
Feb 15 2015 22:23
This message was deleted
Sylvain Corlay
@SylvainCorlay
Feb 15 2015 22:39
Something like
# In HasTraits
    def add_trait(self, traitname, trait):
        """Dynamically add a trait attribute to the HasTraits instance."""
        self.__class__ = type(self.__class__.__name__, (self.__class__,), 
                              {traitname: trait})
        trait.set_default_value(self)

# In Widget
    def add_trait(self, traitname, trait):
        """Dynamically add a trait attribute to the Widget."""
        super(Widget, self).add_trait(traitname, trait)
        if trait.get_metadata('sync'):
             self.keys.append(traitname)
             self.send_state(traitname)