[Python-ideas] combining two threads: switch statements and inline functions
Ryan Gonzalez
rymg19 at gmail.com
Wed Feb 12 01:02:57 CET 2014
I was talking about Chris' code, not yours.
On Tue, Feb 11, 2014 at 6:00 PM, Bruce Leban <bruce at leapyear.org> wrote:
>
> On Tue, Feb 11, 2014 at 3:51 PM, Ryan Gonzalez <rymg19 at gmail.com> wrote:
>
> Uhhh...isn't that the same as a lambda? i.e.:
>>
>
>
> I knew I should have thrown something else in there more than 'return' to
> show I wasn't just doing lambda. See added lines below.
>
> def sample(i, op, j):
> switcher = {{
> '-':: if i > j:
> return i - j
> else:
> return j - i;;
> '+':: return i + j;;
>
> '*':: result = 1
>
> for k in range(j):
>
> result += i
>
> return result;;
>
> '@':: print(i, j)
> raise OopsException();;
>
> }}
> return switcher[op]()
>
>
> I also left out the default case for simplicity.
>
> On Tue, Feb 11, 2014 at 3:47 PM, Andrew Barnert <abarnert at yahoo.com>
> wrote:
>
>> <snip> It's not an accident that the provisional syntax is ugly </snip>
>>
>
> You think that's ugly? I can make it uglier.
>
> --- Bruce
>
--
Ryan
If anybody ever asks me why I prefer C++ to C, my answer will be simple:
"It's becauseslejfp23(@#Q*(E*EIdc-SEGFAULT. Wait, I don't think that was
nul-terminated."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140211/5cee2bf6/attachment-0001.html>
More information about the Python-ideas
mailing list