> Or could you do something like:
>
> arguments_to_pass = [list of some sort]
> switch.get(var, default)(*arguments_to_pass)
Stevens lambda suggestion was most appropriate. Within the switch, there
are functions called with none, or some variation of arguments. It was not
easy to pass them in afte
On 3/10/2013 11:18 AM, Steven D'Aprano wrote:
On Sun, 10 Mar 2013 14:16:27 +, Joseph L. Casale wrote:
I have a switch statement composed using a dict:
switch = {
'a': func_a,
'b': func_b,
'c': func_c
}
switch.get(var, default)()
As a result of multiple functions per choic
On Sun, Mar 10, 2013 at 8:42 PM, Mitya Sirenef wrote:
> On 03/10/2013 10:16 AM, Joseph L. Casale wrote:
>
>> I have a switch statement composed using a dict:
>>
> >
> >
> > switch = {
> > 'a': func_a,
> > 'b': func_b,
> > 'c': func_c
> > }
> > switch.get(var, default)()
> >
> >
> > As a result of
On 03/10/2013 10:16 AM, Joseph L. Casale wrote:
I have a switch statement composed using a dict:
>
>
> switch = {
> 'a': func_a,
> 'b': func_b,
> 'c': func_c
> }
> switch.get(var, default)()
>
>
> As a result of multiple functions per choice, it migrated to:
>
>
>
> switch = {
> 'a': (func_a1,
> switch = {
> 'A': functools.partial(spam, a),
> 'B': lambda b, c=c: ham(b, c),
> 'C': eggs,
> }
>
> switch[letter](b)
That's cool, never even thought to use lambdas.
> functools.partial isn't always applicable, but when it is, you should
> prefer it over lambda since it will
On Sun, 10 Mar 2013 14:16:27 +, Joseph L. Casale wrote:
> I have a switch statement composed using a dict:
>
>
> switch = {
> 'a': func_a,
> 'b': func_b,
> 'c': func_c
> }
> switch.get(var, default)()
>
>
> As a result of multiple functions per choice, it migrated to:
>
>
>
On Thu, 23 Dec 2004 19:57:27 GMT, rumours say that rzed
<[EMAIL PROTECTED]> might have written:
[Why did PEP 275 stall?]
>It seems to me that it was regarded as misguidod.
QOTPE +1
(PE=Python Era)
Oncoming Python book: "Hitchhiker's Guido to the Python Language"
--
TZOTZIOY, I speak England v
Skip Montanaro <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]:
>
> Stephen> {
> Stephen> 'one': lambda x:x.blat(),
> Stephen> 'two': lambda x:x.blah(),
> Stephen> }.get(someValue, lambda x:0)(someOtherValue)
>
> One thing to remember is that function calls in Python are
>