sobering observation, python vs. perl
Marko Rauhamaa
marko at pacujo.net
Thu Mar 17 14:53:08 EDT 2016
BartC <bc at freeuk.com>:
> I was going to suggest just using a function. But never having coded in
> Perl before, I wasn't expecting something this ugly:
>
> sub replacewith{
> $s = $_[0];
> $t = $_[1];
> $u = $_[2];
> $s =~ s/$t/$u/;
> return $s;
> }
>
> Although once done, the original task now looks a proper language:
>
> print (replacewith("I have a dream","have","had"));
Now try your function with:
print (replacewith("I have a dream",".","had"));
Marko
More information about the Python-list
mailing list