You cannot materialize an object from a non-existing reference. Python names *have* to exist for them to work.
Instead, give the `data3` keyword a default, then when the keyword is **not** specified, create the instance:
_sentinel = object()
class my_data():
def __init__(self,data1,data2,data3=_sentinel):
if data3 is _sentinel:
data3 = my_data(None, None, None)
self.data1 = data1
self.data2 = data2
self.data3 = data3
Now you can create instances of `my_data()` with a default new instance for `data3`:
>>> d2 = my_data('a', 'b')
>>> d1 = d2.data3
Because we used a sentinel default value, you can still set `data3` to `None` as well:
>>> d3 = my_data('a', 'b', None)
>>> d3.data3 is None
True