5 ms·
It is not entirely about the syntax, for example, the code looks similar in Python (if I remember Perl correctly): print(f"it turns out that {TV[family]['l
by d0mine 5y ago
It is not entirely about the syntax, for example, the code looks similar in Python (if I remember Perl correctly):
print(f"it turns out that {TV[family]['lead']} has ", end=‘’)
print(len(TV[family]['kids']), " kids named ", end='')
print(*[kid.name for kid in TV[family]['kids']], sep=', ')
For me, it was the culture “there is _one_ obvious (for a Dutch) way to do it” vs. “many” in Perl and most people lack discipline/good taste to handle the [too much] freedom provided by Perl.
Somehow Python took the niche of “executable pseudocode”, “glue language” for me.
- tyingq 5y ago>the code looks similar in Python Minus the sigils and crazy wrapping, like: @{ $TV{$family}{kids} } to refer to the array, but a different sigil/form if you're talking about one element, etc. Which may not look intimidating on its own, but it's leaving out % and the backslash \$reference syntax, $object->method and other things that get confusing. You can't, for example really make a "list of hashes/dicts". Try it, and it just turns the keys/values into array elements. You have to specifically make a "list of references to hashes/dicts". So you do something like: push(@list,\%hash); Then, fun things like a double sigil: foreach my $hashref ( @list ) { print keys %$hashref; } Note there are several ways to do all this, and I am highlighting some of the more visually confusing ones.
- fragmede 5y agoFor printing strings, there is more than one way to do it in Python; differently readable for. print("""It turns out that {} has {} kids named {}""".format( TV[family]['lead'], len(TV[family]['kids'], ', '.join(*[kid.name for kid in TV[family]['kids']]*) ) It doesn't use the nifty f string formatter, but the English sentence part is a bit easier to read.