sobering observation, python vs. perl
Charles T. Smith
cts.private.yahoo at gmail.com
Thu Mar 17 13:25:04 EDT 2016
More information about the Python-list mailing list
Thu Mar 17 13:25:04 EDT 2016
- Previous message (by thread): sobering observation, python vs. perl
- Next message (by thread): sobering observation, python vs. perl
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 17 Mar 2016 19:08:58 +0200, Marko Rauhamaa wrote: > "Charles T. Smith" <cts.private.yahoo at gmail.com>: > > > Compare Perl (<URL: http://www.perlmonks.org/?node_id=98357>): > > my $str = "I have a dream"; > my $find = "have"; > my $replace = "had"; > $find = quotemeta $find; # escape regex metachars if present > $str =~ s/$find/$replace/g; > print $str; > > with Python: > > print("I have a dream".replace("have", "had")) > > > Marko Uh... that perl is way over my head. I admit though, that perl's powerful substitute command is also clumsy. The best I can do right now is: $v = "I have a dream\n"; $v =~ s/have/had/; print $v One of the ugliest things about perl are the "silly" type prefixes ($, @, %). But in a python project I'm doing now, I realized an important advantage that they bring... I want to be able to initialize msgs to communicate with C. Ideally, I'd to just specify the path to an equivalent python instance but all intermediate instances have to already exist - python does not have autovivication. I implemented it but only up until the leaf node - because python doesn't know their types. Perl can do that, because the prefix tells it the type. But, don't get me wrong, coding in python is a JOY!
- Previous message (by thread): sobering observation, python vs. perl
- Next message (by thread): sobering observation, python vs. perl
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list