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
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
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
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
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
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
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
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
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
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
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
.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
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?
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
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
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
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
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
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
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
20 matches
Mail list logo