Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-16 Thread bruceg113355
On Thursday, November 15, 2012 11:16:08 PM UTC-5, Ethan Furman wrote: Emile van Sebille wrote: Using a decorator works when named arguments are not used. When named arguments are used, unexpected keyword error is reported. Is there a simple fix? Extend def

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-16 Thread Ethan Furman
bruceg113...@gmail.com wrote: On Thursday, November 15, 2012 11:16:08 PM UTC-5, Ethan Furman wrote: Emile van Sebille wrote: Using a decorator works when named arguments are not used. When named arguments are used, unexpected keyword error is reported. Is there a simple fix? Extend def

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-15 Thread brucegoodstein
On Saturday, November 10, 2012 10:35:12 AM UTC-5, Aahz wrote: In article mailman.3530.1352538537.27098.python-l...@python.org, Peter Otten __pete...@web.de wrote: Miki Tebeka wrote: Is there a simpler way to modify all arguments in a function before using the arguments

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-15 Thread Emile van Sebille
brucegoodst...@gmail.com wrote: Using a decorator works when named arguments are not used. When named arguments are used, unexpected keyword error is reported. Is there a simple fix? Extend def wrapper(*args) to handle *kwargs as well Emile Code: - from functools import wraps def

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-15 Thread Ethan Furman
Emile van Sebille wrote: brucegoodst...@gmail.com wrote: Using a decorator works when named arguments are not used. When named arguments are used, unexpected keyword error is reported. Is there a simple fix? Extend def wrapper(*args) to handle *kwargs as well Emile Code: - from

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-11 Thread Peter Otten
Aahz wrote: In article mailman.3530.1352538537.27098.python-l...@python.org, Peter Otten __pete...@web.de wrote: Miki Tebeka wrote: Is there a simpler way to modify all arguments in a function before using the arguments? You can use a decorator: from functools import wraps def

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-11 Thread Steve Howell
On Nov 9, 4:48 pm, bruceg113...@gmail.com wrote: Is there a simpler way to modify all arguments in a function before using the arguments? For example, can the below code, in the modify arguments section be made into a few statements?     def someComputation (aa, bb, cc, dd, ee, ff, gg, hh

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread Peter Otten
Miki Tebeka wrote: Is there a simpler way to modify all arguments in a function before using the arguments? You can use a decorator: from functools import wraps def fix_args(fn): @wraps(fn) def wrapper(*args): args = (arg.replace('_', '') for arg in args

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread Chris Angelico
On Sat, Nov 10, 2012 at 3:05 PM, Paul Rubin no.email@nospam.invalid wrote: Chris Angelico ros...@gmail.com writes: Contrived example: def send_email(from, to, subj, body, whatever, other, headers, you, like): That should be a dictionary with the header names as indexes. In fact there are

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread bruceg113355
On Friday, November 9, 2012 8:16:12 PM UTC-5, Steven D'Aprano wrote: On Fri, 09 Nov 2012 20:05:26 -0500, Roy Smith wrote: In article 18134e77-9b02-4aec-afb0-794ed900d...@googlegroups.com, bruceg113...@gmail.com wrote: Is there a simpler way to modify all arguments

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread Aahz
In article mailman.3530.1352538537.27098.python-l...@python.org, Peter Otten __pete...@web.de wrote: Miki Tebeka wrote: Is there a simpler way to modify all arguments in a function before using the arguments? You can use a decorator: from functools import wraps def fix_args(fn

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread bruceg113355
.3530.1352538537.27098.python-l...@python.org, Peter Otten __pete...@web.de wrote: Miki Tebeka wrote: Is there a simpler way to modify all arguments in a function before using the arguments? You can use a decorator: from functools import wraps def fix_args(fn

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-10 Thread Chris Angelico
On Sun, Nov 11, 2012 at 12:15 AM, bruceg113...@gmail.com wrote: Thanks to all. Steve's example is the one I will try next week. Passing in lists, will work but it requires extra coding from the calling routines to build the list. Not necessarily! Watch: def foo(*args):

Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-09 Thread bruceg113355
Is there a simpler way to modify all arguments in a function before using the arguments? For example, can the below code, in the modify arguments section be made into a few statements? def someComputation (aa, bb, cc, dd, ee, ff, gg, hh): # modify arguments

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-09 Thread Roy Smith
In article 18134e77-9b02-4aec-afb0-794ed900d...@googlegroups.com, bruceg113...@gmail.com wrote: Is there a simpler way to modify all arguments in a function before using the arguments? For example, can the below code, in the modify arguments section be made into a few statements

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-09 Thread Steven D'Aprano
On Fri, 09 Nov 2012 20:05:26 -0500, Roy Smith wrote: In article 18134e77-9b02-4aec-afb0-794ed900d...@googlegroups.com, bruceg113...@gmail.com wrote: Is there a simpler way to modify all arguments in a function before using the arguments? For example, can the below code, in the modify

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-09 Thread Paul Rubin
bruceg113...@gmail.com writes: Is there a simpler way to modify all arguments in a function before using the arguments? Why do you want to do that? For example, can the below code, in the modify arguments section be made into a few statements? Whenever someone uses that many variables one

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-09 Thread Chris Angelico
On Sat, Nov 10, 2012 at 1:52 PM, Paul Rubin no.email@nospam.invalid wrote: bruceg113...@gmail.com writes: Is there a simpler way to modify all arguments in a function before using the arguments? Why do you want to do that? Contrived example: def send_email(from, to, subj, body, whatever

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-09 Thread Paul Rubin
Chris Angelico ros...@gmail.com writes: Contrived example: def send_email(from, to, subj, body, whatever, other, headers, you, like): That should be a dictionary with the header names as indexes. In fact there are already some email handling modules in the stdlib that represent headers that

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-09 Thread Miki Tebeka
Is there a simpler way to modify all arguments in a function before using the arguments? You can use a decorator: from functools import wraps def fix_args(fn): @wraps(fn) def wrapper(*args): args = (arg.replace('_', '') for arg in args) return fn(*args) return