I am a student learning Python as well as Perl. In our Perl program we used the code
my $param = shift;
my %local_hash = %$param;
when translating Perl to Python what would be the most similar way to 'shift' the hash or do I no longer need this part of code?
So far I have this in Python
def insert_user(local_hash):
param = shift
local_hash = {param}
user_name = input("Please enter Username: ")
user_name = user_name.replace('\n', '')
You do not even need to look for alternative of shift.
In Perl subroutines are written as below:
sub foo {
my $arg1 = shift;
my @rest_of_args = @_;
...do stuff...
}
In Python you have to define the arguments the function is expecting in function definition syntax.
def foo (arg1, rest_of_args):
...do stuff...
Also see: