Skip to content

MatthieuDartiailh/atom

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to Atom

Atom is a framework for creating memory efficient Python objects with enhanced features such as dynamic initialization, validation, and change notification for object attributes. It provides the default model binding behaviour for the Enaml UI framework.

Illustrative Example:

from atom.api import Atom, Unicode, Range, Bool, observe


class Person(Atom):
    """ A simple class representing a person object.

    """
    last_name = Unicode()

    first_name = Unicode()

    age = Range(low=0)

    debug = Bool(False)

    @observe('age')
    def debug_print(self, change):
        """ Prints out a debug message whenever the person's age changes.

        """
        if self.debug:
            templ = "{first} {last} is {age} years old."
            s = templ.format(
                first=self.first_name, last=self.last_name, age=self.age,
            )
            print(s)

    def _default_first_name(self):
        return 'John'


john = Person(last_name='Doe', age=42)
john.debug = True
john.age = 43  # prints message
john.age = 'forty three'   # raises TypeError

For version information, see the Revision History.

About

Memory efficient Python objects

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 72.0%
  • Python 26.4%
  • C 1.6%