1.1 --- a/micropython/data.py Sat Jun 05 01:39:16 2010 +0200
1.2 +++ b/micropython/data.py Sat Jun 05 15:11:26 2010 +0200
1.3 @@ -206,6 +206,9 @@
1.4 self.namespace[name] = Attr(None, self, name)
1.5
1.6 attr = self.namespace[name]
1.7 + self._set_using_attr(attr, attr_or_value, single_assignment)
1.8 +
1.9 + def _set_using_attr(self, attr, attr_or_value, single_assignment=1):
1.10
1.11 # Handle attribute assignment as well as assignment of basic objects.
1.12 # Attempt to fix the context if not explicitly defined.
1.13 @@ -648,6 +651,11 @@
1.14 self._context_values_str(), self.assignments
1.15 )
1.16
1.17 + def __shortrepr__(self):
1.18 + return "Attr(%r, %s, %r)" % (
1.19 + self.position, shortrepr(self.parent), self.name
1.20 + )
1.21 +
1.22 def _context_values_str(self):
1.23 l = []
1.24 for (c, v) in self.context_values:
1.25 @@ -1157,7 +1165,7 @@
1.26 if isinstance(name, tuple):
1.27 self._add_parameters(name)
1.28 else:
1.29 - self.set(name, None)
1.30 + self.set(name, Instance())
1.31
1.32 def __repr__(self):
1.33 if self.location is not None:
1.34 @@ -1179,9 +1187,15 @@
1.35
1.36 # Namespace-related methods.
1.37
1.38 - def store_default(self, value):
1.39 + def store_default(self, attr_or_value):
1.40 +
1.41 + """
1.42 + Reserve space for defaults, set outside the function, potentially on a
1.43 + dynamic basis, using the 'attr_or_value'.
1.44 + """
1.45 +
1.46 attr = Attr(None, self, None)
1.47 - attr.update([self.get_context_and_value(value)], 1)
1.48 + self._set_using_attr(attr, attr_or_value)
1.49 self.default_attrs.append(attr)
1.50
1.51 def make_global(self, name):