3 ms·
> I've wanted something like that in Python at different times... thanks! Python's auto-vivification doens't allow Perl's hap hazard auto-vivification. Perl al
by irahul 15y ago
> I've wanted something like that in Python at different times... thanks!
Python's auto-vivification doens't allow Perl's hap hazard auto-vivification. Perl allows you to say:
my $foo = {};
$foo->{'blah'}[0]->{'bar'}++;
And after this statement, $foo will refer a hash which has the structure as accessed in the statement.
I don't think this can be done for a generalized case in Python. Whether I want is a totally different question.
- jrockway 15y agoWhy is this haphazard? If you don't want reads to change your data structure shape in a well-defined manner, use 'exists' or make an immutable hash with Hash::Util.