In some languages, like php, you don’t need to manually initialize each dimension of a multidimensional array. You just specify the key path, and the language will automatically initialize the sub arrays if needed.
For example, in php I can just do
$foo = array();
$foo['sub1']['sub2']['sub3'] = 5;
Instead of having to manually initialize each level of sub array
$foo = array();
$foo['sub1'] = array();
$foo['sub1']['sub2'] = array();
$foo['sub1']['sub2']['sub3'] = 5;
I know that python offers this convenience as well I’ve seen python code that appears equivalent, so I figure there’s a name for this feature.
What is the name of this feature?
I believe the corresponding feature in Perl is called autovivification. As the wikipedia page points out, Python dictionaries don’t have this feature by default, but it’s easy to build something that behaves this way by making use of collections.defaultdict. See this recent blog post for some ideas.