Python dot-equals (syntax proposal)

John Bokma john at castleamber.com
Fri Apr 30 13:05:49 EDT 2010


"D'Arcy J.M. Cain" <darcy at druid.net> writes:

> On Fri, 30 Apr 2010 09:04:59 -0700 (PDT)
> Jabapyth <jabapyth at gmail.com> wrote:
>> foo = "Hello world"
>> foo.=split(" ")
>
> Isn't;
>
> foo = "Hello world"
> bar = foo.split() # side note - split() splits on whitespace by default
>
> so much clearer?  Do you really want to see Python turn into Perl?

Oh, boy, there we go again. Can you and your buddies please refrain from
using Perl as a kind of uber-argument? Just write why you think it's
wrong. Bonus points if you can use Python in your arguments.

Why I am asking this is that most "Oh, like Perl" statements I've seen
the past months were made by people who either haven't used Perl
themselves or have very little skill in the language. This is a Python
group.

On top of that, it's not possible in Perl (heh, no surprise there). The
only thing that comes close is:

for ( $a_very_long_variable_name ) {
 
    s/foo/bar/g;
    s/baz/woot/g;
    s/o+/i/g;
}

Which makes $_ an alias for $a_very.... and since s/// defaults to $_
this works.

-- 
John Bokma                                                               j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development



More information about the Python-list mailing list