Let's look at an innocuous piece of ruby. Consider some view code showing a user's name and phone number:
"#{first_name} #{last_name} #{phone}"
Great - this is very succinct, readable, and can easily be extracted to a method in a
#http://kbyanc.blogspot.com/2007/07/python-aggregating-function-arguments.html | |
def arguments(): | |
"""Returns tuple containing dictionary of calling function's | |
named arguments and a list of calling function's unnamed | |
positional arguments. | |
""" | |
from inspect import getargvalues, stack | |
posname, kwname, args = getargvalues(stack()[1][0])[-3:] | |
posargs = args.pop(posname, []) |
# Script to configure web application servers | |
### Supporting functions ############################################################### | |
function Install-Features($RolesToInstall) { | |
$args = @("/Online") | |
$args += "/Enable-Feature" | |
foreach ($role in $RolesToInstall) { | |
$args += "/FeatureName:$role" | |
} | |
& $env:windir\system32\dism $args |