|
Baby Language Lab Scripts
A collection of data processing tools.
|
A primitive enum class (Python has none). More...

Public Member Functions | |
| def | __init__ |
| Constructor. More... | |
| def | __getattr__ |
| This is a Python hook method for retreival by direct key name (eg. More... | |
| def | __iter__ |
| This is a Python hook method for iteration. More... | |
| def | __len__ |
| This is a Python hook method for for returning length. More... | |
| def | __getitem__ |
| This is a Python hook method for indexing. More... | |
| def | get_ordered_vals |
| Returns a list of the values contained in this Enum, in the order in which they were specified when passed to the constructor. More... | |
| def | get_ordered_keys |
| Returns a list of the keys contained in this Enum, in the order in which they were specified when passed to the constructor. More... | |
Static Public Member Functions | |
| def | from_dict |
| Static method to create an Enum from a dictionary of key-value pairs. More... | |
Public Attributes | |
| elements | |
A primitive enum class (Python has none).
Sample usage:
Note: Names should not override any Python internal class varibles (i.e. don't pass in names starting with '__'), or bad things will happen.
| def utils.enum.Enum.__init__ | ( | self, | |
| names, | |||
vals = None |
|||
| ) |
| def utils.enum.Enum.__getattr__ | ( | self, | |
| name | |||
| ) |
This is a Python hook method for retreival by direct key name (eg.
Animals.COW).
| self | |
| name | (string) name of the attribute to retrieve from this instance |
| def utils.enum.Enum.__getitem__ | ( | self, | |
| index | |||
| ) |
This is a Python hook method for indexing.
| self | |
| index | (int) the index of the element to look up - elements are indexed in the order the keys were in when they were passed to the constructor |
| def utils.enum.Enum.__iter__ | ( | self | ) |
| def utils.enum.Enum.__len__ | ( | self | ) |
|
static |
Static method to create an Enum from a dictionary of key-value pairs.
If the Enum is created with an unordered dictionary, the get_ordered_vals() and get_ordered_keys() methods will return values in an unspecified order.
| src_dict | (Dictionary) a dictionary of key-value pairs to insert into the Enum |
| def utils.enum.Enum.get_ordered_keys | ( | self | ) |
| def utils.enum.Enum.get_ordered_vals | ( | self | ) |