SPUG: Grep syntax
Bill Campbell
bill at celestial.com
Fri Jun 15 12:55:36 PDT 2007
On Fri, Jun 15, 2007, Yitzchak Scott-Thoennes wrote:
>On Fri, June 15, 2007 9:53 am, Michael R. Wolf wrote:
>> You mentioned the 'x' operator with a scalar LHS.
>>
>> With a list LHS, it behaves like the Python idiom you mentioned...
>>
>> my @bcopy = (255) x @b;
>
>Saying it that way ("With a list LHS") makes it sound like a violation
>of two rules:
>
>First, that operators provide context to their operands, not vice versa.
>The operator is what decides if what's on it's left is a list or a scalar.
>(For instance, my @bcopy = @b x 1; sets @bcopy to contain a single element
>whose value is the number of elements in @b, not a copy of all the elements
>in @b.)
>
>Second, related to the first, parentheses don't make a list. $x = (255)
>is no different than $x = 255.
My bad. That was a typo. It should have been
bcopy = [255] * len(a)
I do use parenthesis on many expressions in python and perl to
make it easier to find the end of statements with ``%'' in vi,
and to eliminate the necessity of backwhacking continuation lines
which is prone to mysterious errors if one has whitespace beyond
the ``\'' character.
Bill
--
INTERNET: bill at Celestial.COM Bill Campbell; Celestial Software, LLC
URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676
``The meek shall inherit the Earth, the rest of us will go to the stars...''
-Dr. Isaac Asimov
More information about the spug-list
mailing list