# HG changeset patch # User Paul Boddie # Date 1277664948 -7200 # Node ID 036c789784e35e6f4538e78cfddaa079bcb71194 # Parent 7775a7a9fbbfb4c11b95c74e8ef5580eb4b4cb34 Moved methods, added comments and docstrings. diff -r 7775a7a9fbbf -r 036c789784e3 micropython/data.py --- a/micropython/data.py Sat Jun 19 02:14:58 2010 +0200 +++ b/micropython/data.py Sun Jun 27 20:55:48 2010 +0200 @@ -123,6 +123,11 @@ def __getitem__(self, name): return self.namespace[name] + def get(self, name, default=None): + return self.namespace.get(name, default) + + # Specialised access methods. + def get_using_node(self, name, node): """ @@ -144,6 +149,15 @@ def _get_with_scope(self, name, external=0): + """ + Find the source of the given 'name', returning the attribute object, + scope (constant, local, global or builtins), and the full name of the + source namespace (or None for constants). + + If the optional 'external' flag is set to a true value, only external + (non-local) namespaces will be involved in the search. + """ + module = self.module builtins = module and module.builtins or None importer = module and module.importer or None @@ -173,8 +187,7 @@ else: return None, None, None - def get(self, name, default=None): - return self.namespace.get(name, default) + # Attribute definition methods. def __setitem__(self, name, value): self.set(name, value)