You can’t use
getattr() to look stuff up in a dictionary.
But the ‘default’ feature of
getattr() is so useful.
What’s the dict way to do the same thing?
The ternary operator is a way to concisely say:
“If test, then a, else b“,
with the value of the statement being the value of a or b.
pip is hands down my favorite way to install stuff in Python.
If you need to use it behind a firewall, download [Read more…]
Search and replace is such a common task that it should be a tool that’s in every command line script author’s toolbox.
There are probably endless solutions to the problem.
I’ve put together my standard methods for tackling the problem.
I’ll also show similar Perl versions, mainly for comparisons.