[Python-ideas] Another way to avoid clumsy lambdas, while adding new functionality
Chris Angelico
rosuav at gmail.com
Wed Mar 5 13:33:11 CET 2014
On Wed, Mar 5, 2014 at 4:15 PM, Cameron Simpson <cs at zip.com.au> wrote:
> On 05Mar2014 04:06, MRAB <python at mrabarnett.plus.com> wrote:
>> On 2014-03-05 01:46, Cameron Simpson wrote:
>> >> a = $(foo + 1)
>> >
>> >Definitely nicer. Still irrationally uncomfortable about the "$" though.
>> >A thought, though it could break existing code (and nested tuples, alas):
>> > a = (( foo + 1 ))
>> >
>> That's not a tuple. It's equivalent to:
>> a = foo + 1
>
> I know that. I should have said: though the below looks nice, in more complicated forms it fights with tuples, eg:
>
> ((1,2,3),(4,5,6))
> (((1,2,3),(4,5,6)))
Bikeshedding the syntax without expressing an opinion on the feature:
Using {{ }} would be safer. The inner one might be interpreted as a
dict or a set, but neither of those can go into a set, so it'd be
illogical. Whether the similarity with C-style block delimiters is a
good thing or a bad thing remains to be seen :)
ChrisA
More information about the Python-ideas
mailing list