Created
February 20, 2014 19:42
-
-
Save joeheyming/9121639 to your computer and use it in GitHub Desktop.
example of python and perl named/keyword arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python | |
def printArgs(*args, **kwargs): | |
print kwargs | |
>>> printArgs(a=1, b=2) | |
{'a': 1, 'b': 2} | |
# perl | |
use Data::Dumper; | |
sub printArgs { | |
my %args = @_; | |
print Dumper(\%args); | |
} | |
printArgs(a => 1, b => 2) | |
$VAR1 = { | |
'a' => 1, | |
'b' => 2 | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment